This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: sizeof and allignment on 32bit target
- From: Jan Zizka <ziza at klubicko dot net>
- To: Eric de Jong <list_ericdejong_10 at gmx dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 25 Jul 2003 11:34:24 +0300
- Subject: Re: sizeof and allignment on 32bit target
- References: <000b01c35284$ad78c640$e33922c7@ericnt>
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