Newsgroups: comp.lang.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Subject: Re: Help needed with: sizeof (struct a)
Message-ID: <1991Jun22.160729.280@thunder.mcrcim.mcgill.edu>
Keywords: sizeof,struct,help,cc
Organization: McGill Research Centre for Intelligent Machines
References: <10569@aspect.UUCP>
Date: Sat, 22 Jun 91 16:07:29 GMT
Lines: 19

In article <10569@aspect.UUCP>, dave@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@larry.mcrcim.mcgill.edu
