vscode c++ 编译可以通过 但是有红色波浪线的问题
SegmentFault
共 1892字,需浏览 4分钟
·
2020-08-04 11:12
作者:送外卖转行计算机
来源:SegmentFault 思否
1.command + p, 然后输入 >C/C++
选择 编辑配置(JSON)
然后在工作区会出现一个.vscode文件夹, 其中会有一个.json文件的配置
2.打开命令行 输入
gcc -v -E -x c++ -
会有以下的信息
`ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)
End of search list.`
将上面的路径复制到刚刚的json文件中
如图
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include/**",
"/Library/Developer/CommandLineTools/usr/include/c++/v1/**",
"/Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/include/**",
"/Library/Developer/CommandLineTools/usr/include/**",
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/**",
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/**"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/usr/local/bin/gcc-7",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
注意要在后面加 /**
然后红色波浪线就不会出现了。
评论