无法在VSCode中设置C++调试;无法识别调试类型
Unable to setup C++ debugging in VSCode; Debug type not recognized
我正在尝试设置VSCode以开始学习C++。作为其中的一部分,我需要能够调试代码,所以我安装了带有.vsix文件的C/C++扩展名,以允许它添加C++调试配置。然而,当我尝试设置配置时,我并不认为C++是环境的一个选项;只有node、gdb和lldb。按照这里的说明,我在命令面板中没有看到任何关于C++的建议。因此,我手动设置任务、c_cpp_properties和launch.json文件,并根据需要复制、粘贴和修改路径。但是,VSCode将launch.json中的cppdbg标记为未识别为调试类型,并将字段stopAtEntry、environments、MIMode和miDebuggerPath标记为"不允许使用属性<…>"。如果我将其更改为gdb,它会识别调试类型,但属性不允许的错误仍然存在:
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**", "${vcpkgRoot}/x86-windows/include"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:\dev\tools\mingw64\bin\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": ["test.cpp"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/test.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"console": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\dev\tools\mingw64\bin\gdb.exe"
}
]
}
我使用的VSCode版本较旧,为1.19。我编写代码的HelloWorld/test.cpp文件非常简单:
#include <iostream>
#include <string>
int main()
{
std::cout << "Type your name" << std::endl;
std::string name;
std::cin >> name;
std::cout << "Hello, " << name << std::endl;
return 0;
}
有人能告诉我在这个过程中遗漏了什么吗?因为到目前为止,我还没能在谷歌上找到任何东西。
在我的案例中,我没有在vscode中安装Microsoft C/C++扩展。我使用docker容器进行开发,在连接到我的docker容器后,我需要安装这个扩展。
我收到了同样的错误消息,结果发现我的launch.json文件中列出了两种不同的配置。我以为我会在跑步周期中选择一个,一切都会好起来的。事实证明,我不得不指出未使用的启动配置,以消除错误消息。(gdb) Launch
很好,指出了整个Linux版本lldb
- 使用 MSVC 调试类型
- C++需要所有声明的类型说明符和预期的非限定 id(需要调试帮助)
- 当前不会命中断点。没有调试器目标代码类型的可执行代码与此文件关联
- 为自定义打印调试实现传递任何类型的变量
- 无法在VSCode中设置C++调试;无法识别调试类型
- Vulkan API 调试函数指针类型转换错误
- QT创建者和MSVC-忽略调试时特定的异常类型
- C++ 显示字符串变量"<不完整类型>的调试窗口
- 在小对象优化中调试崩溃以进行类型擦除
- LLDB调试器 - 定义自定义类型显示
- Visual Studio-使用PDB进行调试,但缺少类型信息
- 使用推力调试不完整的类型错误
- 如何调试此由类型特征引起的错误
- 警告LNK4206:找不到预编译类型信息; 未链接或覆盖;链接对象,就好像没有调试信息一样
- 自定义 CMake 配置类型。我可以以某种方式从调试中"inherit"吗?
- VS Studio调试器-获取(并观察)一个类型的所有实例
- Visual Studio 2010调试器可视化Qt图像类型
- 如何调试regasm(注册什么类型)
- 在调试器中查看大多数派生类型
- 在调试器中自动显示已知类型和长度的void*(数组)