原标题:vscode c++ 编译可以通过 但是有红色波浪线的问题

219faa2011be5ebcb920c477ba5628bd.png

作者:送外卖转行计算机

来源:SegmentFault 思否

1.command + p, 然后输入 >C/C++

11be500c6ef0615c7175e886f80cb563.png

选择 编辑配置(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

}

注意要在后面加 /**

然后红色波浪线就不会出现了。返回搜狐,查看更多

责任编辑:

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐