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.