pushpack1.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // Clang
  10. //
  11. //
  12. // USAGE:
  13. //
  14. // struct StructToBePacked {
  15. // } PACK_STRUCT;
  16. //
  17. // ===============================================================================
  18. // Modified by Yao Wei Tjong for Urho3D
  19. // Suppress 'gcc_struct' is being ignored warnings when compiling for Raspberry-PI
  20. #ifdef AI_PUSHPACK_IS_DEFINED
  21. # error poppack1.h must be included after pushpack1.h
  22. #endif
  23. #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
  24. # pragma pack(push,1)
  25. # define PACK_STRUCT
  26. #elif defined( __GNUC__ )
  27. # if defined(__clang__) || defined(RASPI)
  28. # define PACK_STRUCT __attribute__((__packed__))
  29. # else
  30. # define PACK_STRUCT __attribute__((gcc_struct, __packed__))
  31. # endif
  32. #else
  33. # error Compiler not supported
  34. #endif
  35. #if defined(_MSC_VER)
  36. // C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop
  37. # pragma warning (disable : 4103)
  38. #endif
  39. #define AI_PUSHPACK_IS_DEFINED