This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: No Packing in GCC


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]