Irrlicht 3D Engine
irrpack.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012 Nikolaus Gebhardt
00002 // This file is part of the "Irrlicht Engine".
00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
00004 
00005 // include this file right before the data structures to be 1-aligned
00006 // and add to each structure the PACK_STRUCT define just like this:
00007 // struct mystruct
00008 // {
00009 //  ...
00010 // } PACK_STRUCT;
00011 // Always include the irrunpack.h file right after the last type declared
00012 // like this, and do not put any other types with different alignment
00013 // in between!
00014 
00015 // byte-align structures
00016 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
00017 #   pragma warning(disable: 4103)
00018 #   pragma pack( push, packing )
00019 #   pragma pack( 1 )
00020 #   define PACK_STRUCT
00021 #elif defined( __DMC__ )
00022 #   pragma pack( push, 1 )
00023 #   define PACK_STRUCT
00024 #elif defined( __GNUC__ )
00025     // Using pragma pack might work with earlier gcc versions already, but
00026     // it started to be necessary with gcc 4.7 on mingw unless compiled with -mno-ms-bitfields.
00027     // And I found some hints on the web that older gcc versions on the other hand had sometimes
00028     // trouble with pragma pack while they worked with __attribute__((packed)).
00029 #   if (__GNUC__ > 4 ) || ((__GNUC__ == 4 ) && (__GNUC_MINOR__ >= 7))
00030 #       pragma pack( push, packing )
00031 #       pragma pack( 1 )
00032 #       define PACK_STRUCT
00033 #   else
00034 #       define PACK_STRUCT  __attribute__((packed))
00035     #endif
00036 #else
00037 #   error compiler not supported
00038 #endif
00039