目录

  1. Windows中VS code debug时无法查看C++ STL容器内容
    1. 而我相应的配置文件如下:
    2. 1、.vscode\tasks.json
    3. 2、.vscode\launch.json
    4. 3、 .vscode\c_cpp_properties.json
  2. 附上我的电脑的环境配置

Windows中VS code无法查看C++ STL容器的值 - 解决方法 编辑

Windows中VS code debug时无法查看C++ STL容器内容

首先,你很可能用的是x64版本的Windows。


我发现一个有效的解决方法,但在x64版本的Windows上安装MinGW时,虽然官方推荐MinGW版本的是x86_64的,但实践后发现如果选择安装 x86_64的, 很可能Debug时会无法看到STL容器(vecotr、map等)的具体信息,看到的是相应的内存地址~

故建议选 i686 (win32)的,然后安装步骤的下一步及后面的操作都按默认的来就好。

MinGW-x86版


最后的效果:
pretty-printing-not-work-with-MinGW GDB-solution

win32 版本的 MinGW官方下载地址:

i686-posix-dwarf


我从这里下载到 MinGW 压缩包,然后解压到文件夹 D:\MinGW 中,接下来把MinGW的bin目录,即 D:\MinGW\i686-8.1.0-release-posix-dwarf-rt_v6-rev0\mingw32\bin 加到了系统变量的 PATH 中。

将MinGW添加到系统变量

而我相应的配置文件如下:

1、.vscode\tasks.json

JSON
{
"tasks": [
{
// "type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}

2、.vscode\launch.json

JSON
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{ // Display content in STL containers pretty
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}

3、 .vscode\c_cpp_properties.json

JSON
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "g++", // Or complete absolute path "D:/MinGW/i686-8.1.0-release-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe"
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x86"
}
],
"version": 4
}

附上我的电脑的环境配置

hljs
VSCode Version: 1.53.2 (system setup)
OS Version: Windows 10 x64 (Windows_NT x64 10.0.19041)
MinGW version: i686-8.1.0-release-posix-dwarf-rt_v6-rev0
GDB version: 8.1.0 (Target: i686-w64-mingw32)

希望对你有用, 有问题请留言交流~

本文作者: 极客中心
原文地址: https://www.geekzl.com/windows-vs-code-cpp-stl-not-work.html
本文地址:www.geekzl.com/windows-vs-code-cpp-stl-not-work.html



作者:极客玩家
出处:https://geekzl.com

如果,您希望更容易地发现我的新文章,不妨点击一下绿色通道的关注我,亦可微信搜索公众号大白技术控关注我。

如果您觉得阅读本文对您有帮助,请点击一下右下方的推荐按钮,您的推荐将是我写作的最大动力!
版权声明:本文为博主原创或转载文章,欢迎转载,但转载文章之后必须在文章页面明显位置注明出处,否则保留追究法律责任的权利。如您有任何疑问或者授权方面的协商,请          .
posted @   大白技术控  阅读(1801)  评论(1编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?

打赏

>>

欢迎打赏支持我 ^_^

扫描二维码打赏

了解更多

点击右上角即可分享
微信分享提示