Size of structure containing char fields
Henry Spencer
henry at zoo.toronto.edu
Thu Jul 19 01:25:00 AEST 1990
In article <1030 at lzaz.ATT.COM> bds at 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 at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list