Check out my first novel, midnight's simulacra!

Endianness

From dankwiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

You oughtn't ever need deal with endianness unless you're doing one of three things:

  • Writing a specification for a network protocol or file format
  • Reading/writing to a network
  • Reading/writing to an external file

Compilation

If your compiler isn't properly folding down constant expressions involving byteswaps, the following are defined in linux's asm/byteorder.h:

  • __constant_htons()
  • __constant_ntohs()
  • __constant_htonl()
  • __constant_ntohl()