Bytes alignement problem with arm-linux-gcc
Frederic Kwiatkowski
stagedrt@gmail.com
Thu Feb 8 10:55:00 GMT 2007
Hi all
I'm actually working with arm-linux-gcc 3.4.4 and i've noticed a bug
when using union. Indeed i've written the following union but sizes
doesn't match the reallity:
typedef union _t_paquet{
unsigned char msg[14];
struct _NAMEDFIELD{
unsigned char error ;
unsigned long entete ;
unsigned char len ;
unsigned char data[8] ;
} NAMEDFIELD;
}t_paquet ;
Normally we will have the following sizes:
sizeof(a.msg) = 14
sizeof(a.NAMEDFIELD.error) = 1
sizeof(a.NAMEDFIELD.entete) = 4
sizeof(a.lNAMEDFIELD.en) = 1
sizeof(a.NAMEDFIELD.data) = 8.
So we can think that sizeof(a.msg)=sizeof(a.NAMEDFIELD) but
sizeof(a.NAMEDFIELD)=20 ...
How can this problem can be resolved? Is there a specific compilation
option for alignement problems?
With regards
Frederic
More information about the Gcc-bugs
mailing list