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

1.command + p, 然后输入 >C/C++
image.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

}

注意要在后面加 /**

然后红色波浪线就不会出现了。

你可能感兴趣的:(c++)