1. middle-endian/mixed-endian
https://en.wikipedia.org/wiki/Endianness#Middle-endian
2. When is htonl(x) != ntohl(x) ?
3. 用一个语句判断大小端
1 int isLittleEndian(void)
2 { 3 return *(char *)(int []){1} == 1; 4 }
关于Compound Literals,https://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Compound-Literals.html
htonl
andntohl
would not be the same.htonl
would have to rotate left by 8 bits, andntohl
would have to rotate right by 8 bits. – jxh May 22 '15 at 3:08