GCC 预定义宏: Endian

#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
// little endian
#elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
// big endian
#elif (__BYTE_ORDER__ == __ORDER_PDP_ENDIAN__)
// pdp endian, The bytes in 16-bit words are laid out in
// a little-endian fashion, whereas the 16-bit subwords of
// a 32-bit quantity are laid out in big-endian fashion. 
#endif

Over!

Leave a Reply

Your email address will not be published. Required fields are marked *