Check out my first novel, midnight's simulacra!

Endianness

From dankwiki
Revision as of 08:33, 14 December 2011 by Dank (talk | contribs) (Created page with "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 net...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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()