Check out my first novel, midnight's simulacra!

Endianness: Difference between revisions

From dankwiki
Jump to navigation Jump to search
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..."
 
(No difference)

Latest revision as of 08:33, 14 December 2011

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