MAC OSX stdio.h file not found

今天发现在命令行用clang编译一个普通的c文件时报错:

fatal error: ‘stdio.h’ file not found

查了一下,普遍的说法是:

安装xcode-select($ xcode-select --install),接着安装 /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg

这种方法不行,我在CommandLineTools文件夹下没有找到Packages,后来找到了一个很好用的方法:

$ export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)

这个方法最大的好处是不用手动去找库文件位置,把这行命令添加到/etc/profile文件就行,不过我运行$ xcrun --sdk macosx --show-sdk-path指令得到的SDK路径是

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

这是在Xcode应用内,不确定没有装Xcode的mac会是什么结果