Re: No Packing in GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux