Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on A review of endianness bugs in Qt, and how they were fixed. Parent comment
Except it is. On x86, which is little endian, compilers are smart enough to convert it to a mov.
> These functions will either swap, or not, depending on the endianness of the target machine
So will the above. Here's the MIPS little endian version:
read_int32(unsigned char*): lwl $2,3($4) j $31 lwr $2,0($4)
read_int32(unsigned char*): lbu $3,1($4) lbu $2,2($4) sll $5,$3,8 lbu $6,0($4) sll $3,$2,16 lbu $2,3($4) or $3,$5,$3 or $3,$3,$6 sll $2,$2,24 j $31 or $2,$3,$2
There are no comments on this comment yet.
Except it is. On x86, which is little endian, compilers are smart enough to convert it to a mov.
> These functions will either swap, or not, depending on the endianness of the target machine
So will the above. Here's the MIPS little endian version:
This doesn't swap. The MIPS big endian version: This swaps and ors. What part of this do you not consider portable between different-endian machines?