Is there a portable equivalent of __attribute__ ((__packed__))
(by portability I mean working on PC, Android and iPhones, regardless architecture)
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.
By definition,
__attribute__s are non-portable. If you want your data a specific way, the Plan9 solution is usually to useunsigned chararrays in your structure:Usually won’t have any alignment, since it’s fundamentally using unsigned characters. Of course, if you have a high tolerance for pain, you could always use an
enumof offsets:You could then load it up like so:
As long as you have the stomach for it, it will be completely portable.