Is __attribute__((packed))
GCC only, or cross platform?
If it's GCC only, how can I check if I am compiling on GCC?
So I can do this for a cross-platform packed structure:
#if /*COMPILING_ON_GCC*/# define Packed __attribute__((packed))#else# define Packed#endifstruct MyStruct { char A; int B; long C; //...} Packed;
If it's GCC, Packed
will be replaced with __attribute__((packed))
, and if it's not, it will be replaced with nothing, and not cause any problems.
BTW I LOVE POUND DEFINE MACROS!!!