Re: Bytes alignement problem with arm-linux-gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Frederic Kwiatkowski writes:

 > 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?

Look up 'Type Attributes' in the Fine Manual.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux