1

我想在我的 Xcode 项目中使用“BYTE_ORDER”宏,但我不能,因为我不知道它是在哪个标头中定义的。

4

1 回答 1

0

当我查看我的 Xcode 4.3.X 安装时,我发现 " byte_order.h" 文件位于几个地方:

[/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform]:;!fi
find . -name byte_order.h -print
./Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/architecture/byte_order.h
./Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/machine/byte_order.h
./Developer/SDKs/MacOSX10.6.sdk/usr/include/architecture/byte_order.h
./Developer/SDKs/MacOSX10.6.sdk/usr/include/architecture/i386/byte_order.h
./Developer/SDKs/MacOSX10.6.sdk/usr/include/architecture/ppc/byte_order.h
./Developer/SDKs/MacOSX10.6.sdk/usr/include/machine/byte_order.h
./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/architecture/byte_order.h
./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/machine/byte_order.h
./Developer/SDKs/MacOSX10.7.sdk/usr/include/architecture/byte_order.h
./Developer/SDKs/MacOSX10.7.sdk/usr/include/architecture/i386/byte_order.h
./Developer/SDKs/MacOSX10.7.sdk/usr/include/machine/byte_order.h

你可能想#include <architecture/byte_order.h>在你的 .c 文件中做一个 "" 来获取 byte_order 宏。

对于实际的“ BYTE_ORDER”定义本身,它是在几个特定的​​地方定义的,但它的定义方式似乎意味着非常特定的目的。例如,这个定义:

#define __DARWIN_BYTE_ORDER __DARWIN_LITTLE_ENDIAN
#define BYTE_ORDER  __DARWIN_BYTE_ORDER
./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/i386/endian.h

仅适用于内核扩展(驱动程序)。

这定义:

#     define BYTE_ORDER LITTLE_ENDIAN
#     define BYTE_ORDER BIG_ENDIAN
#  endif /* BYTE_ORDER */
#  define X_BYTE_ORDER BYTE_ORDER
./Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/X11/Xarch.h

适用于 X11 的东西(ewww)。

我想说最好的办法是NXHostByteOrder在“”文件中使用“”内联函数byte_order.h,这将为您提供当前主机的字节顺序。

于 2012-06-17T22:35:34.177 回答