I have been trying to look up this problem but have not found a solution that works. My compiler is ignoring #pragma pack(push) #pragma pack(2) and __ attribute __ ((aligned (2), packed)) does not solve problem as well. The stack is 8 byte aligned and want to convert some structures to be 2 byte aligned. -fpack-struct works but it affects all structures.
I would like to use #pragma pack.
I am programming a xilinx microblaze in SDK 13.3 eclipse IDE GCC #4.1.2
I guess I dont understand what is making the compiler ignore the Pragma pack.. I dont want to turn the warnings off I would like to use it.
#pragma pack(push)
#pragma pack(2)
struct _Size_Test
{
union
{
struct{
int8 x;
int8 y;
};
int16 z;
};
}Size_Test;
#pragma pack(pop)
sizeof(Size_test) = 4 when it should be 2
adding attribute((aligned(2),packed)) does not work
struct _Size_Test
{
union
{
struct{
int8 x;
int8 y;
};
int16 z;
};
}Size_Test _attribute_((aligned(2),packed));