1 /* this file mimics the macros present in recent GCC and CLANG */
6 /* This are prefixed with UTIL to avoid collisions
8 * You can use something like the following to define UTIL_BYTE_ORDER
9 * in a configure script.
14 uint32_t test = 0x34333231;
15 int main() { printf("%.4s\n", (const char*)&test); return 0; }
18 #define UTIL_ORDER_BIG_ENDIAN 4321
19 #define UTIL_ORDER_LITTLE_ENDIAN 1234
22 #if !defined(UTIL_BYTE_ORDER) || ((UTIL_BYTE_ORDER != UTIL_ORDER_BIG_ENDIAN) && \
23 (UTIL_BYTE_ORDER != UTIL_ORDER_LITTLE_ENDIAN))
24 #undef UTIL_BYTE_ORDER
26 # if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
27 # define UTIL_BYTE_ORDER UTIL_ORDER_LITTLE_ENDIAN
28 # elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
29 # define UTIL_BYTE_ORDER UTIL_ORDER_BIG_ENDIAN
31 # error "Unsupported __BYTE_ORDER__"
34 # error "UTIL_BYTE_ORDER not correctly defined and __BYTE_ORDER__ not defined."