gcc_struct, old fish, but reinterpreted: 92f4c84488

pull/505/head
Ser Lev Arris 2015-03-21 11:08:06 +01:00
parent 3e6043de70
commit a7e4babd9d
1 changed files with 46 additions and 46 deletions

View File

@ -1,46 +1,46 @@
// =============================================================================== // ===============================================================================
// May be included multiple times - sets structure packing to 1 // May be included multiple times - sets structure packing to 1
// for all supported compilers. #include <poppack1.h> reverts the changes. // for all supported compilers. #include <poppack1.h> reverts the changes.
// //
// Currently this works on the following compilers: // Currently this works on the following compilers:
// MSVC 7,8,9 // MSVC 7,8,9
// GCC // GCC
// BORLAND (complains about 'pack state changed but not reverted', but works) // BORLAND (complains about 'pack state changed but not reverted', but works)
// Clang // Clang
// //
// //
// USAGE: // USAGE:
// //
// struct StructToBePacked { // struct StructToBePacked {
// } PACK_STRUCT; // } PACK_STRUCT;
// //
// =============================================================================== // ===============================================================================
#ifdef AI_PUSHPACK_IS_DEFINED #ifdef AI_PUSHPACK_IS_DEFINED
# error poppack1.h must be included after pushpack1.h # error poppack1.h must be included after pushpack1.h
#endif #endif
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack(push,1) # pragma pack(push,1)
# define PACK_STRUCT # define PACK_STRUCT
#elif defined( __GNUC__ ) #elif defined( __GNUC__ )
# if defined(__clang__) # if !defined(HOST_MINGW)
# define PACK_STRUCT __attribute__((__packed__)) # define PACK_STRUCT __attribute__((__packed__))
# else # else
# define PACK_STRUCT __attribute__((gcc_struct, __packed__)) # define PACK_STRUCT __attribute__((gcc_struct, __packed__))
# endif # endif
#else #else
# error Compiler not supported # error Compiler not supported
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
// C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop // C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop
# pragma warning (disable : 4103) # pragma warning (disable : 4103)
#endif #endif
#define AI_PUSHPACK_IS_DEFINED #define AI_PUSHPACK_IS_DEFINED