Acki, how likely is it that the OP is using the IBM VisualAge C++ compiler? I'd guess that it is _very_ unlikely. It is much more likely that he is using MSVC. The best way to find out is to ask. I bring this up because the functionality is different between compilers, and you link to documentation that is most likely wrong for this user. If he is indeed using the Microsoft compiler,
here is the documentation for that.
pippy, what you have posted is pretty close. I don't know if why would possibly want 3 byte packing, but that isn't a supported value [only 1, 2, 4, 8 and 16 are valid]. I think you want this...
Code: Select all
#pragma pack (push, 1)
// declare types with 1 byte packing
#pragma pack (pop)
You should note that modifying the packing of structures can result in worse performance than if you had left the packing at the default.
Travis