This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sizeof and allignment on 32bit target


Hi,

On Fri, Jul 25, 2003 at 10:13:30AM +0200, Eric de Jong wrote:
>    struct TestStruct
>    {
>       struct
>       {
>          unsigned long Value1;
>          unsigned long Value2;
>          unsigned short Value3;
>       } Value;
>       unsigned long Value4;
>    } Test;

if you should get those 10 you have to add packed attribute to the struct
definition:

    struct TestStruct
    {
       struct
       {
          unsigned long Value1;
          unsigned long Value2;
          unsigned short Value3;
       } Value __attribute__ ((packed));
       unsigned long Value4;
    } Test __attribute__ ((packed));

otherwise the alignment will be always 4 bytes for any structure.

-ziza



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]