macOS Catalina上的头文件丢失

时间:2019-10-12 07:27:42

标签: macos gcc

我在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);

我在MacOS Catalina上挖掘了头文件和gcc,并使用this答案作为参考点。答案指出

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中返回什么?

1 个答案:

答案 0 :(得分:0)

请参考此解决方案。我昨天在那儿回答了。如果您通常编写C / C ++代码并在/usr/include中查找C / C ++头文件或以前的头文件,这将很有用。但是在Catalina中,此更新没有/usr/include文件夹,并且由于系统安装了只读模式,您可能无法创建/usr/include文件夹。

Can't compile a C program on a Mac after upgrading to Catalina 10.15

您可以尝试此解决方案。