3 ms·
__attribute__((packed)) in GCC is probably worth mentioning if you only want to apply it to selected structs.
by danellis 13y ago
__attribute__((packed)) in GCC is probably worth mentioning if you only want to apply it to selected structs.
- YZF 13y ago#pragma pack(push) #pragma pack(1) MSVC
- eps 13y ago#pragma pack(push, 1) // :)
- pjscott 13y agoGCC also supports that pragma, for compatibility with MSVC: http://gcc.gnu.org/onlinedocs/gcc/Structure-Packing-Pragmas.html http://gcc.gnu.org/onlinedocs/gcc/Structure-Packing-Pragmas.... Clang has this, too.
- userbinator 13y agoAnd MSVC doesn't support GCC's pragma, so for optimal portability #pragma pack(1) is my preferred way of doing it.