我觉得我的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
?我是要下载一个新的编译器,还是误用我现有的编译器? 最佳答案
试试这个:
cc -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include -L/usr/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/lib -licucore /tmp/esc.c
如果不起作用,我建议您安装“Unicode的国际组件”:
1) Install Macports for OS X
2) Run this in Terminall app: "port install icu"
它提供了unicode所需的所有组件,包括“/opt/local/include/unicode/uchar.h”
然后为cc找到合适的选项:
/opt/local/bin/icu-config --cppflags-searchpath --ldflags --ldflags-icuio
它给你:
-I/opt/local/include -L/opt/local/lib -licui18n -licuuc -licudata -licuio
所以你把你的程序编译成:
cc -I/opt/local/include -L/opt/local/lib -licui18n -licuuc -licudata -licuio /tmp/esc.c
我不确定,但也许从它的网站上获得重症监护病房对你也有帮助:
http://site.icu-project.org/download
关于c - 在OS X 10.9上找不到uchar.h文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24608832/