XCode 4.3中的stdlib.h文件位置是什么?

9

请告诉我,XCode 4.3 中 stdlib.h 的位置在哪里?


1
我不能确定4.3版本,但在我的机器上使用XCode 4.2,locate stdlib.h | grep /stdlib\.h$ 输出如下:/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/tr1/stdlib.h /Developer/SDKs/MacOSX10.6.sdk/usr/include/stdlib.h /usr/include/c++/4.2.1/tr1/stdlib.h /usr/include/stdlib.h - Andrey Starodubtsev
@darkmist Apple将Xcode 4.3捆绑到单个应用程序包中,现在很难找到东西... - Jake Badlands
3个回答

7

Xcode 4.3之前版本中的/Developer目录现在已经整合到Xcode.app包中。每个支持的SDK和平台都有一个对应的文件:

$ find /Applications/Xcode.app -name stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/include/c++/4.2.1/tr1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/include/c++/4.2.1/tr1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/tr1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/tr1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/stdlib.h

非常感谢!你不仅告诉了我在哪里找到它,还介绍了一个很好的查找其他头文件的方法! - Jake Badlands

5
如果您安装了命令行工具 (Xcode > Preferences > Downloads),那么该文件位于 /usr/include/stdlib.h

1
我认为您应该使用unistd.h而不是stdlib.h。当导入stdlib.h时,我在尝试使用sleep()时遇到了问题,我不得不导入unistd.h

stdlib 是 POSIX 指定的。你不应该绕过它。bames53(下面)给出了正确的答案(通用解决方案,即使是非 Xcode 命令行构建)。trojanfoe(上面)回答了一个未被问到的问题(与 Xcode 构建有关)。此外,有时您没有那种自由度(stdlib.h -> unistd.h)。 - jww

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接