little endian: the first read is the least. 首先读取的字节为最低位字节;
big endian: the first read is the biggest. 首先读取的字节为最高位字节。
在阅读SWISH-E源代码的时候,看到了一个判断机器是little endian还是big endian 的方法,很是巧妙(作者说也是从网上浏览到的,呵呵,原创是谁就不知道了)。
#ifndef LITTLE_ENDIAN
const int endian_test_value = 1;
#define LITTLE_ENDIAN (*(const unsigned char* )&endian_test_value
#endif
在使用的时候,直接用 if (LITTLE_ENDIAN)