iPhone平台:字节顺序(检测和交换) [英] iPhone platform: endianness (detection & swapping)

查看:101
本文介绍了iPhone平台:字节顺序(检测和交换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iPhone上进行一些对字节序敏感的文件操作。在该环境中是否存在标准宏或#defines,表示本机字节顺序并在必要时提供交换?我知道我可以提前检查并为这个特定的架构做正确的事情,但想知道是否有更清洁的方法来做正确的事情。 (文件格式是小端;如果是big-endian,我可能只使用htons / htonl系列。)

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

谢谢。

推荐答案

OSByteOrder.h 中有一整套标准宏和函数:

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

例如 http://www.opensource。 apple.com/source/xnu/xnu-1456.1.26/libkern/libkern/OSByteOrder.h

这篇关于iPhone平台:字节顺序(检测和交换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆