Packing a Structure
Last updated on
Sometimes you need to pack a struct, particularly when dealing with networking with different architectures/compilers. Heres a handy cross platform way of doing it.
#ifndef _MSC_VER
#define PACK(structure) structure __attribute__((__packed__))
#else
#define PACK(structure) __pragma(pack(push, 1)) structure __pragma(pack(pop))
#endif