Help needed with: sizeof (struct a)

der Mouse mouse at thunder.mcrcim.mcgill.edu
Sun Jun 23 02:07:29 AEST 1991


In article <10569 at aspect.UUCP>, dave at aspect.UUCP (Dave Corcoran) writes:
> My Sun cc prints 4 for both structs, prints 3 for the array

> struct a {char x;char y;char z};
> struct b {char x[3]};
> char c[3];
[code to print out sizeof() the above things omitted -dM]

> Is there any way to cause cc to force sizeof return the actual size
> of the structs without rounding up to the next highest sizeof(short)?

It *is* returning the actual size of the structs.  The size of a struct
is defined to include any padding the compiler sees fit to include.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list