我的 Mac 上的 VS Code 产量#包含错误 for 头文件 and 第三方库 (wxWidgets在这种情况下)。我阅读了我能找到的所有内容,调整了“c_cpp_properties.json”中的“includePath”设置,但没有任何帮助。
头文件与 .cpp 文件位于同一文件夹中(“/src/”)。该项目构建并运行良好,但 VS Code 产生 #include 错误,并且错误曲线覆盖了我的整个项目。
下面是屏幕截图和带有 VS Code 设置的 JSON 文件。
#包含错误截图 https://i.stack.imgur.com/qdINX.png
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
}
请帮我解决这个问题。
————— UPDATE —————
建议我使用以下设置c_cpp_properties.json:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${vcpkgRoot}/x64-osx/include",
"/usr/local/Cellar/wxmac/3.0.5/**"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
头文件#include 错误消失了,但是第三方库(“WX”)错误仍然存在。在上面的 JSON 中,“includePath”中写入了“${vcpkgRoot}/x64-osx/include”行。
这是vcpkg https://github.com/Microsoft/vcpkg有助于轻松安装第三方库的软件包。
安装后vcpkg,我安装了wxWidgets via vcpkg,但该库未在 VS Code 中链接(不过构建得很好),并且我收到错误曲线,如下面的屏幕截图所示:
您能解释一下如何纠正它吗?