how to pack data using gcc compiler?

James E Wilson wilson@specifixinc.com
Thu Jan 27 04:29:00 GMT 2005


Michael Sung wrote:
> b) Is there a compiler flag for gcc compiler that will pack all data 
> structures?

But note that this option will pack everything, including structures 
defined in system header files, which means your program will no longer 
be compatible with your C library unless you also recompile your C 
library this way.  And then you have to worry about system calls too if 
you have any that take structures, which means you might need to 
recompile parts of your kernel.

It is almost always wrong to use this option.  Better is to use 
__attribute__ ((pack)), or #pragma pack, that way you can control what 
gets packed.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc mailing list