structure alignement 1 byte

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Wed Feb 9 13:22:00 GMT 2000


> 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


More information about the Gcc mailing list