about gcc compiler option
DavidSmith at byu.net
Mon Nov 28 07:55:25 MST 2005
> On Mon, Nov 28, 2005 at 06:05:00AM +0000, Jason Holt wrote:
> sizeof (foo) is not necessarily the same as the amount of space
> required by foo. Processors that require alignment on word boundaries
> (e.g. PDP-11, 68000) may force padding.
Indeed, even on modern x86 systems gcc may pad the 1-byte "bool" with 3
unused bytes to word-align it, especially if it is the last member of a
struct. Not sure what this would do on a 64-bit system...
For example, unless the -fpack-struct is specified, this structure will
occupy 8 bytes (as reported by sizeof):
It should probably also be noted that C does not have a bool type, and a
simple char is generally used instead.
More information about the PLUG