Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22097

Is __attribute__((packed)) GCC only, or cross platform?

$
0
0

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!!!


Viewing all articles
Browse latest Browse all 22097

Trending Articles