views:

366

answers:

1

Hi all, I'm doing some endian-sensitive file manipulation on iPhone. Are there standard macros or #defines in that environment that indicate native endianness and offer swapping if necessary? I know I can check in advance and just do the right thing for this particular architecture, but wondering if there are cleaner ways of doing the right thing. (The file format is little endian; if it were big-endian, I'd probably just use the htons/htonl family.)

Thanks.

+1  A: 

There is a full set of standard macros and functions for this in OSByteOrder.h:

e.g. http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/libkern/libkern/OSByteOrder.h

quixoto