You can define PACK like as follows for GNU GCC
and MSVC
:
#ifdef __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
#endif
And use it like this:
PACK(struct myStruct
{
int a;
int b;
});