Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Portability of Misaligned Data Access . . . . . . .



On 28/07/06, Ian Wells <ijw@example.com> wrote:

On point (2), let it be noted that you *never*, *ever* have to
discover the endianness of your host:

uint16_t read_le_u16(char *x) {
   return (uint16_t)x[0]+(((uint16_t)x[1]) <<8);
}

How about just always using htons(3) and htonl(3) to get compatible byte orders?

-Josh


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links