macOS Catalina缺少头文件

3

我在 macOS Catalina 上遇到了头文件的问题。我遇到了以下类似于命令行工具错误的问题:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:29: error: parameter name omitted
 int     getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
                             ^~~

和 GCC 错误

/usr/local/Cellar/gcc@8/8.3.0/lib/gcc/8/gcc/x86_64-apple-darwin18/8.3.0/include-fixed/math.h:535:15: error: storage class specified for parameter 'nextafte'
 extern double nextafter(double, double);

我查看了头文件和gcc,使用这个回答作为参考。该回答表明:

Regarding header locations, I have Apples headers in /Library/Developer/CommandLineTools/:

$ sudo find /Library -name stdio.h 
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.
当我运行相同的命令时,标题位置略有不同:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h

如您所见,SDK现在已经分为MACOSX10.14和10.15,与以往不同。另一个区别是头文件。根据参考答案,

if you install gcc via brew, it will add headers in /usr/local/:

$ sudo find /usr -name stdio.h 
/usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0/tr1/stdio.h
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include/ssp/stdio.h
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include-fixed/stdio.h
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/tr1/stdio.h
/usr/local/Cellar/gcc/8.1.0/lib/gcc/8/gcc/x86_64-apple-darwin17.5.0/8.1.0/include/ssp/stdio.h
/usr/local/Cellar/gcc/8.1.0/lib/gcc/8/gcc/x86_64-apple-darwin17.5.0/8.1.0/include-fixed/stdio.h
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/tr1/stdio.h
/usr/local/Cellar/gcc/7.3.0_1/lib/gcc/7/gcc/x86_64-apple-darwin17.3.0/7.3.0/include/ssp/stdio.h
/usr/local/Cellar/gcc@7/7.3.0/include/c++/7.3.0/tr1/stdio.h
/usr/local/Cellar/gcc@7/7.3.0/lib/gcc/7/gcc/x86_64-apple-darwin17.5.0/7.3.0/include/ssp/stdio.h
/usr/local/Cellar/gcc@7/7.3.0/lib/gcc/7/gcc/x86_64-apple-darwin17.5.0/7.3.0/include-fixed/stdio.h
/usr/local/include/c++/8.2.0/tr1/stdio.h
/usr/local/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include/ssp/stdio.h
/usr/local/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include-fixed/stdio.h
然而,当我运行以上命令时,我得到以下结果:
/usr/local/Cellar/gcc@8/8.3.0/include/c++/8.3.0/tr1/stdio.h
/usr/local/Cellar/gcc@8/8.3.0/lib/gcc/8/gcc/x86_64-apple-darwin18/8.3.0/include/ssp/stdio.h
/usr/local/Cellar/gcc@8/8.3.0/lib/gcc/8/gcc/x86_64-apple-darwin18/8.3.0/include-fixed/stdio.h

其他的头文件在哪里?这些命令在 macOS Catalina 中应该返回什么?


我有相同的问题。在OSX 10.14中,/Include中的所有头文件都可以从/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg安装,但是在10.15下没有相同的pkg文件。 - akh22
有什么建议吗?如果您遇到相同的问题,是否可以点个赞/分享一下呢?也许已经解决此问题的其他人会看到这个问题。 - rrz0
1个回答

0

参考此解决方案。我昨天已经在那里回答了。如果您通常编写C/C++代码并寻找C/C++头文件或以前的头文件,则这将非常有用,它们位于/usr/include中。但是,在Catalina中,从此更新开始就没有/usr/include文件夹,您可能无法创建/usr/include文件夹,因为系统会以只读模式挂载。

在升级到Catalina 10.15后无法在Mac上编译C程序

您可以尝试此解决方案。


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