Kladdehelvete
How do you know what kind of alignment will performed to the start of that structure?
If my memory doesn't fail me, that should tell msvc to pack the members at one byte granularity, meaning that if you have (for instance)
| struct foo
{
char a;
int b;
short c;
};
|
the sizeof() would be 1+4+2 instead of 4+4+4 for dword packing.
Historically I remember seeing the pragma pack() being used to "easily" load binary files off disk, but that's a rather fragile thing portability-wise (especialy if we get to small/big endianess things). The only other reason I can think of is if you want to save memory if you're allocating truly enormous amount of those structures. Or maybe for cache optimization, but that would go into the "premature optimization" bin in this case.
Apart from those, it's better to leave the packing alone and let the compiler generate stuff that's fast to access.