how to pack data structures (i386)?
Andi Kleen
ak@suse.de
Wed Apr 11 20:23:00 GMT 2001
Will Menninger <william.l.menninger@boeing.com> writes:
> Hello,
>
> I've found gcc to be an extremely reliable compiler. Thanks for your
> efforts. I have a question for you:
>
> I'm using gcc (2.7.something) with an i386 system. Is there a compiler
> option or a #pragma statement I can use to have it pack data structures
> as tightly as possible (e.g. not pad char's out to 4-bytes)?
See the gcc manual, "C extensions", "Variable attributes"
Basically you add __attribute__((packed)) to a structure definition.
Newer gcc should also be able to understand #pragma pack for compatibility,
not sure if 2.7.* does though; it's a rather old compiler.
-Andi
More information about the Gcc
mailing list