This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Bytes alignement problem with arm-linux-gcc
- From: "Frederic Kwiatkowski" <stagedrt at gmail dot com>
- To: gcc-help at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Cc: "Frederic Kwiatkowski" <stagedrt at gmail dot com>
- Date: Thu, 8 Feb 2007 11:55:35 +0100
- Subject: Bytes alignement problem with arm-linux-gcc
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