Structure Packing alignment


Hi guys,

Do any of you know how to set packing alignment to structure in GCC (or should I say compiling for Wismo Target)? I’m using OpenAT 3.01 and i’ve only recently discovered, #pragma pack(1) only works in Debug mode but does not work in Wismo Target.

Hence, a structure eg.

#pragma pack(1)
typedef struct 
    char FirstMember;
    char SecondMember;

sizeof(Structure_T); would return 2 if packed into a single byte


IT RETURNS 4 when compiled for Wismo Target.

So obviously it is packing into 4 byte lengths instead of 1. Does anyone know how to pack into a single byte length for Wismo Target?


Hi Yul,

I hardly found it too, this is a known problem with gcc.
You should write :

#pragma pack(1)
typedef struct
    char FirstMember;
    char SecondMember;
} __attribute__((__packed__)) Structure_T;

but only when compiled for Wismo Target
So I do:

 #define ATTRIBUTE_PACKED __attribute__((__packed__))

and ATTRIBUTE_PACKED is used on each structure

Best regards,



You can use “GNUC” macro, it is automatically defined with GCC compiler.



I’ve just been caught by this, too! :angry:

If it’s a “known problem with gcc”, is this documented somewhere? Do you have a link?
Any idea if there’s any plans to fix it?