This is the mail archive of the gcc@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]

Re: structure alignement 1 byte


> We are using the gcc 2.7.2.3 on a SuSE linux system installed on a intel pc.
> 
> We need structure alignment 1 byte bounary.
> 
> Which compilerflag have to be set to get 1 byte alignment ?
> 
> Can you help me?

The -fpack-struct is the flag that gives that feature. Please note
that it affects *all* structures, including those defined in the C
library. So if you want to run the programs on Linux, the option is
not useful. Instead, you should set the alignment on a per-structure
basis, such as

struct X{
  int i;
  char c;
}__attribute__((packed));

struct X f[2]={1,2,3,4};

Hope this helps,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]