BRE12
pushpack1.h
1 
2 
3 // ===============================================================================
4 // May be included multiple times - sets structure packing to 1
5 // for all supported compilers. #include <poppack1.h> reverts the changes.
6 //
7 // Currently this works on the following compilers:
8 // MSVC 7,8,9
9 // GCC
10 // BORLAND (complains about 'pack state changed but not reverted', but works)
11 // Clang
12 //
13 //
14 // USAGE:
15 //
16 // struct StructToBePacked {
17 // } PACK_STRUCT;
18 //
19 // ===============================================================================
20 
21 #ifdef AI_PUSHPACK_IS_DEFINED
22 # error poppack1.h must be included after pushpack1.h
23 #endif
24 
25 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
26 # pragma pack(push,1)
27 # define PACK_STRUCT
28 #elif defined( __GNUC__ )
29 # if defined(__clang__)
30 # define PACK_STRUCT __attribute__((__packed__))
31 # else
32 # define PACK_STRUCT __attribute__((gcc_struct, __packed__))
33 # endif
34 #else
35 # error Compiler not supported
36 #endif
37 
38 #if defined(_MSC_VER)
39 
40 // C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop
41 # pragma warning (disable : 4103)
42 #endif
43 
44 #define AI_PUSHPACK_IS_DEFINED
45 
46