Detect Platform Endianness in C
#ifndef ENDIAN_H #define ENDIAN_H #include <stdint.h> int isBigEndian() { union { uint32_t i; char c[4]; } e = { 0x01000000 }; return e.c[0]; } #endif // #define ENDIAN_H