如何在Mac上的VS Code中处理C ++头文件#include错误?

问题描述 投票:0回答:1

Mac上的VS代码对头文件第三方库产生#include错误(在这种情况下为WXMac)。我阅读了所有可以找到的内容,并在“ c_cpp_properties.json”中调整了“ includePath”设置,但无济于事。

头文件与.cpp文件(“ / src /”)位于同一文件夹中。该项目的构建和运行良好,但是VS Code产生#include错误,并且错误代码覆盖了我的整个项目。

下面是屏幕截图和带有VS Code设置的JSON文件。

#include error screenshot

c_cpp_properties.json:

{
"configurations": [
    {
        "name": "Mac",
        "includePath": [
            "${workspaceFolder}/src",
            "${workspaceFolder}/**",
            "/usr/local/Cellar/wxmac/3.0.5.1/include/wx-3.0"
        ],
        "defines": [],
        "macFrameworkPath": [
            "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
        ],
        "compilerPath": "/usr/bin/g++",
        "cStandard": "c11",
        "cppStandard": "c++17"
    }
],
"version": 4

}

[请帮助我理顺这一点。

c++ visual-studio-code clang vscode-settings llvm-clang
1个回答
0
投票

includePath属性上,将**添加到目录路径的末尾:

...
"includePath": [
    "${workspaceFolder}/src/**",
    "${workspaceFolder}/**",
    "/usr/local/Cellar/wxmac/3.0.5.1/include/wx-3.0/**"
 ],

您可以在c_cpp_properties.json上查找有关documentation的更多详细信息,>

© www.soinside.com 2019 - 2024. All rights reserved.