iPhone platform: endianness (detection & swapping)

2020-06-28 04:47发布

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条回答
我欲成王,谁敢阻挡
2楼-- · 2020-06-28 05:27

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

查看更多
登录 后发表回答