Detecting #pragma pack support?

Bob Bradley bob@chaoticsoftware.com
Wed May 9 01:24:00 GMT 2007


Is there a way to detect whether #pragma pack( push, n ) is supported? Some
targets seem to support it in some versions of GCC and some don't so I was
hoping there was some kind of preprocessor symbol I can check to see which
one I should use at compile time. I have to support other compilers in
addition to GCC so I can't use the packed attribute. I essentially want to
do this:

#if PRAGMA_PACK_PUSH_SUPPORTED
    #pragma pack( push, 2 )
#elfif PRAGMA_PACK_SUPPORTED
    #pragma pack( 2 )
#else
    #error pragma pack not supported at all
#endif

Is there a way to detect this with GCC?




More information about the Gcc-help mailing list