大小端和字节序

1. middle-endian/mixed-endian

https://en.wikipedia.org/wiki/Endianness#Middle-endian

2. When is htonl(x) != ntohl(x) ?

https://stackoverflow.com/questions/11617684/when-is-htonlx-ntohlx-or-when-is-converting-to-and-from-network-byte-o

So, a crazy machine may have a 8 bits right rotated from network byte order as its host byte order. On such a machine, htonl and ntohl would not be the same. htonl would have to rotate left by 8 bits, and ntohl would have to rotate right by 8 bits. –jxh May 22 ’15 at 3:08

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

关于爱情的句子:情不知所起,一往而情深。

大小端和字节序

相关文章:

你感兴趣的文章:

标签云: