pushpack1.h 1.1 KB

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