sizeof struct

Henry Spencer henry at utzoo.uucp
Thu Sep 7 02:37:47 AEST 1989


In article <29722 at pbhya.PacBell.COM> afh at PacBell.COM (Alan Hobesh) writes:
>The following c code prints the size of the definded structure to be 44,
>when compiled on an AT&T 3B20 running UNIX V5.2.1....
>However, when the code is downloaded to a PC and compiled using Turbo C,
>the size of the structure is reported to be 42.
>
>Why is there a difference and which is the correct size?

There is a difference because compilers use different rules for filling
in structures.  Both sizes are correct; code that assumes *any* specific
size for a struct is wrong.
-- 
V7 /bin/mail source: 554 lines.|     Henry Spencer at U of Toronto Zoology
1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list