jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Mon Jun 02, 2008 9:03 pm Post subject: struct padding avoidance |
|
|
I would like to set up a struct and avoid alignment in it. According to a website:
| Quote: | | Although the standard didn't provide any control in customizing the alignment and padding rules, many compilers provide this through non-standard extensions. |
But in wikipedia i found:
| Quote: | | ...some compilers use #pragma directives to specify packing inside source files... |
| Code: | #pragma pack(push) /* push current alignment to stack */
#pragma pack(1) /* set alignment to 1 byte boundary */
struct MyPackedData
{
char Data1;
long Data2;
char Data3;
};
#pragma pack(pop) /* restore original alignment from stack */ |
| Quote: | | The above directives are available in compilers from Microsoft, Borland, GNU and many others. |
Just to stop those already writing "use search", this has nothing to do with __attribute__((aligned(16))) and i'm not experimenting directly the above code because my app has unexpected behaviours at the moment and i would not recognize the changes. If someone already had the same problem and wish to save me time writing some test code, then feel free to tell me if "#pragma pack(1) " works properly, or otherwise what's the pspsdk replacement if any. Thanks for your attention. |
|