我的印象是我的 C 编译器支持 C11,因为它接受 -std=c11 标志,
$ cc --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
uchar.h
是 C11 标准的一部分,所以我希望这个程序能够编译,
$ cat /tmp/esc.c
#include <uchar.h>
int main(void) {}
但是
$ cc /tmp/esc.c
/tmp/esc.c:1:10: fatal error: 'uchar.h' file not found
#include <uchar.h>
^
1 error generated.
我尝试找到 uchar.h 文件,但奇怪的是,我系统上唯一的命中来自 iPhone SDK,
$ locate uchar.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/unicode/uchar.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include/unicode/uchar.h
如何在 OS X 10.9 上使用 uchar.h
?我是否需要下载一个新的编译器,或者我是否滥用了已有的编译器?
最佳答案
Apple 的 macOS(直到并包括 Catalina 10.15)都没有 <uchar.h>
也不<threads.h>
.它没有 <uchar.h>
中声明的 4 个函数或使用 char16_t
的任何其他功能或 char32_t
.
移植到需要这些功能的 Mac 的代码必须重写以避免使用它们(至少在 macOS 上),或者由提供 macOS 所需功能的条件编译代码支持。
关于c - 在 OS X 10.9 上找不到 uchar.h 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24608832/