Xref: utzoo comp.std.c:3392 comp.lang.c:30352 Newsgroups: comp.std.c,comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Size of structure containing char fields Message-ID: <1990Jul18.152500.4591@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1030@lzaz.ATT.COM> Date: Wed, 18 Jul 90 15:25:00 GMT In article <1030@lzaz.ATT.COM> bds@lzaz.ATT.COM (Bruce Szablak) writes: >Given a structure that contains only char fields (possibly unsigned): > > struct example1 { char a, b, c; }; > >is ANSI restrictive enough [;-)] to force sizeof(example1) to be 3? >Is anyone aware of existing compilers for which this wouldn't be true? ANSI more or less leaves the question open. Machines on which char pointers are strange will almost certainly pad the structure to a word boundary so they can use "normal" pointer format for `struct example1 *'. Some compilers on more ordinary machines may do likewise. Some won't. -- NFS: all the nice semantics of MSDOS, | Henry Spencer at U of Toronto Zoology and its performance and security too. | henry@zoo.toronto.edu utzoo!henry