iPhone platform: endianness (detection & swapping)

ⅰ亾dé卋堺 提交于 2019-12-21 06:01:46

问题


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:


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



来源:https://stackoverflow.com/questions/2704721/iphone-platform-endianness-detection-swapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!