irrpack.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2007-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. // include this file right before the data structures to be 1-aligned
  5. // and add to each structure the PACK_STRUCT define just like this:
  6. // struct mystruct
  7. // {
  8. // ...
  9. // } PACK_STRUCT;
  10. // Always include the irrunpack.h file right after the last type declared
  11. // like this, and do not put any other types with different alignment
  12. // in between!
  13. // byte-align structures
  14. #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
  15. # pragma warning(disable: 4103)
  16. # pragma pack( push, packing )
  17. # pragma pack( 1 )
  18. # define PACK_STRUCT
  19. #elif defined( __DMC__ )
  20. # pragma pack( push, 1 )
  21. # define PACK_STRUCT
  22. #elif defined( __GNUC__ )
  23. // Using pragma pack might work with earlier gcc versions already, but
  24. // it started to be necessary with gcc 4.7 on mingw unless compiled with -mno-ms-bitfields.
  25. // And I found some hints on the web that older gcc versions on the other hand had sometimes
  26. // trouble with pragma pack while they worked with __attribute__((packed)).
  27. # if (__GNUC__ > 4 ) || ((__GNUC__ == 4 ) && (__GNUC_MINOR__ >= 7))
  28. # pragma pack( push, packing )
  29. # pragma pack( 1 )
  30. # define PACK_STRUCT
  31. # else
  32. # define PACK_STRUCT __attribute__((packed))
  33. #endif
  34. #else
  35. # error compiler not supported
  36. #endif