No Packing in GCC
John Love-Jensen
eljay@adobe.com
Tue Jan 16 17:00:00 GMT 2007
Hi Jeremy,
Packing is off by default. At least on the platforms I'm familiar.
You can use the -fpack-struct to enable maximum packing (equivalent to
-fpack-struct=1).
You can use, for example, the -fpack-struct=2 to enable maximum structure
packing on even boundaries. Depending on your platform, the value is
probably required to be a power of 2, and depending on your linker, may top
out.
You can specify minimum alignment (minimum packing) of, say, 2 bytes in the
code by using the __attribute__((align(2))) tag, or packing using the
__attribute((packed)) tag. These would be on a struct-by-struct basis (or
variable-by-variable basis).
Here are the URLs on the documentation:
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Type-Attributes.html
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Code-Gen-Options.html
HTH,
--Eljay
More information about the Gcc-help
mailing list