[lug] OFF: sizeof structs in gcc?

Tkil tkil at scrye.com
Thu Jun 7 14:22:34 MDT 2001

>>>>> "Scott" == Scott A Herod <herod at interact-tv.com> writes:

Scott> Ahhh, I found it.  The info page on gcc says to use pack you
Scott> must first #define HANDLE_PRAGMA_PACK_PUSH_POP 1

[slight reordering here]

Scott> The info page has a LOT more information that the man page.
Scott> Looks like there is even a variable `STRUCTURE_SIZE_BOUNDARY'.

these are both macros that are used only by machine description files,
so far as i can tell.  you really want the __attribute__ stuff instead.

Scott> The windows code that I am porting was sending a class across a
Scott> socket connection.  I confess to having done the same thing
Scott> myself in the past, but think that it's pretty evil.  ( Of
Scott> course my current code won't work on a big-endian machine
Scott> talking to a little-endian. )

glad that you know this.  :) the c faq has a subtle rebuke in it:

   Q 2.12:  My compiler is leaving holes in structures, which is
            wasting space and preventing ``binary'' I/O to external
            data files. Can I turn off the padding, or otherwise
            control the alignment of structure fields?

note the scare quotes around "binary"...


More information about the LUG mailing list