首页 > 解决方案 > VS Code:局部变量未正确显示

问题描述

抱歉,如果以前有人问过这个问题,但我没有得到以前给出的答案。我是 VS Code 的新手,并且知道一点 C++ 编码。我尝试了 windows/mingw 的教程: https ://code.visualstudio.com/docs/cpp/config-mingw#_step-through-the-code 并完成了所有工作。示例代码已经构建,我现在想调试,但是在调试时单步执行应用程序时,我的变量视图显示了一些不同的内容。(见附图) 在此处输入图像描述 这个词应该包含任何字符串,以及 msg 应该显示不同的东西。不过,我的自制手表显示正确。这是怎么回事?我按照教程做了所有事情。

另外:终端选项卡不会从 cout 输出味精,但我会在调试控制台中看到它。(参见“设置手表”一章上方教程中的图片)

启动.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": "g++.exe - Aktive Datei erstellen und debuggen",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Automatische Strukturierung und Einrückung für \"gdb\" aktivieren",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

抱歉,我是 vs 代码的新手:-/

标签: c++visual-studio-codemingw-w64

解决方案


我使用 sourceforge 的 64 位版本的 MinGW 重新安装,因为我有一个通过 mingw-get 运行的旧 32 位版本。


推荐阅读