MAC环境下 VS Code中C语言头文件不存在

vs code写好代码之后头文件下方出现波浪线表示错误,需要路径设置

#include errors detected. Please update your includePath. IntelliSense features for this translation unit (/Users/…/Desktop/ctest/main.c) will be provided by the Tag Parser.

解决方法是
在命令行里面输入gcc -v -E -x c++ -在结果里面找到头文件目录,

#include <…> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks (framework directory)
End of search list.

将这些路径值,全部copy到c_cpp_properties.json文件中的includePath字段下,警告消失

在这里插入图片描述
新的问题出现
在命令后运行gcc -v -E -x c++ - 出现一下错误警告
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

解决方法:

打开终端输入

xcode-select --install

回车后,系统弹出下载xcode,点击确认,下载完成后即可。(实际上不是下载xcode,可能下载xcode有关插件,下载时长约1分钟)

出现这个错误原因猜想可能是因为之前安装过xcode卸载后出现的。

然后就顺利解决了。

c_cpp_properties.json

c_cpp_properties.json

注意路径之间要用逗号分开,并且加上引号哦~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值