gpt4 book ai didi

c++ - Visual Studio Code : C/C++: Multiple definitions for a header/include file shown; how to fix?

转载 作者:太空宇宙 更新时间:2023-11-04 12:33:21 32 4
gpt4 key购买 nike

我在 Windows 上使用 VSCode 1.37.1 和 mingw64-5.4.0。我已经按照 https://code.visualstudio.com/docs/cpp/config-mingw 上的 VSCode C++ 配置教程进行操作。但我在解析头文件位置时遇到问题。在代码编辑器中,如果我将光标放在“ ”上,然后按 F12,我将转到该文件。但是,如果我将光标放在“ ”上并按 F12,我会看到一个小弹出窗口,显示三种不同的可能分辨率。请参见下面的屏幕截图。

我可以选择手动选择正确的文件并打开它,但下次我通过 F12 打开同一个文件时它会再次询问。

VSCode 已经检测到正确的包含路径(见下文),并且正确的文件只存在于其中一个路径中,因此它应该已经具有所有必需的信息。

我的问题是:如何告诉 VSCode 自动打开由包含路径确定的正确文件,而不是像这样提示我?

截图:

Screenshot of VSCode popup with multiple definitions

通过使用“C/C++:日志诊断”选项板命令,我看到 VSCode 已检测到正确的包含路径(与命令提示符下的“g++ -v empty.c”相比)。完整的诊断是:

-------- Diagnostics - 8/28/2019, 10:32:51 PM
Version: 0.25.0
Current Configuration:
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.15063.0",
"compilerPath": "D:/opt/mingw64-5.4.0/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"compilerArgs": [
"-m64"
],
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Translation Unit Mappings:
[D:\wrk\learn\vscode\cpphello\helloworld.cpp]:
D:\WRK\LEARN\VSCODE\CPPHELLO\HELLOWORLD.CPP
[D:\opt\mingw64-5.4.0\x86_64-w64-mingw32\include\c++\debug\vector]:
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++\DEBUG\VECTOR
Translation Unit Configurations:
[D:\wrk\learn\vscode\cpphello\helloworld.cpp]:
Process ID: 9088
Memory Usage: 19 MB
Compiler Path: D:/opt/mingw64-5.4.0/bin/g++.exe
Includes:
D:\OPT\MINGW64-5.4.0\LIB\GCC\X86_64-W64-MINGW32\5.4.0\INCLUDE
D:\OPT\MINGW64-5.4.0\LIB\GCC\X86_64-W64-MINGW32\5.4.0\INCLUDE-FIXED
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++\X86_64-W64-MINGW32
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++\BACKWARD
Defines:
_DEBUG
UNICODE
_UNICODE
Standard Version: c++17
IntelliSense Mode: gcc-x64
Other Flags:
--g++
--gnu_version=50400
[D:\opt\mingw64-5.4.0\x86_64-w64-mingw32\include\c++\debug\vector]:
Process ID: 10728
Memory Usage: 33 MB
Compiler Path: D:/opt/mingw64-5.4.0/bin/g++.exe
Includes:
D:\OPT\MINGW64-5.4.0\LIB\GCC\X86_64-W64-MINGW32\5.4.0\INCLUDE
D:\OPT\MINGW64-5.4.0\LIB\GCC\X86_64-W64-MINGW32\5.4.0\INCLUDE-FIXED
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++\X86_64-W64-MINGW32
D:\OPT\MINGW64-5.4.0\X86_64-W64-MINGW32\INCLUDE\C++\BACKWARD
Defines:
_DEBUG
UNICODE
_UNICODE
Standard Version: c++17
IntelliSense Mode: gcc-x64
Other Flags:
--g++
--gnu_version=50400
--header_only_fallback
Total Memory Usage: 52 MB

最佳答案

我提交了 CppTools Issue 4186: Multiple definitions shown for header/include file but only one is on includePath为此,它作为 Issue 2564: Go to Definition on a #include path doesn't use the IntelliSense info 的拷贝被关闭.

看来这只是一个已知错误,没有已知的解决方法。

关于c++ - Visual Studio Code : C/C++: Multiple definitions for a header/include file shown; how to fix?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57704144/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com