I need to set the struct alignment in XCode to 1-byte packing, and adding the pragma “#pragma pack(1)” doesn’t seem to have any effect.
Is there another way to do this?
I have to read legacy data, so hand-packing is not an option.
Thanks,
Bill
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
XCode is using GCC, so you must use GCC specific instructions : http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Type-Attributes.html
For example :
This struct will thus be aligned with a minimum of 1 byte.
You also have the packed attribute, which specify that no padding should be added.
EDIT
I forget to mention but as @Stephen Chu mentionned it, MSVC style pragma are also supported by GCC : http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html