Robscot75
Robscot75

Reputation: 91

VS Code: local variables not showing correctly

Sorry if this has been asked before, but I don't get the previous given answers. I'm new to VS Code and know a bit of c++ coding. I tried the tutorial for windows/mingw : https://code.visualstudio.com/docs/cpp/config-mingw#_step-through-the-code and done everything so far. The sample code has been build and I want to debug now, but my variables view is showing something different when stepping through the application when debugging. (see attached image) enter image description here The word should contain any of the strings, as well as msg should show something different. My watch for a self made i int shows correctly, though. Whats'up? I did everything as in the tutorial.

also: the terminal tab does not output the msg from cout, but I see it in the debug console instead. (see image in tutorial just above the chapter 'set a watch')

launch.json is:

{
    // 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"
        }
    ]
}

sorry, i'm a newb to vs code :-/

Upvotes: 6

Views: 7268

Answers (2)

Ielixmar
Ielixmar

Reputation: 58

One possible cause is that pretty-printing did not display UTF-8 content correctly. You can either:

  1. Set it to UTF-8 charset (VSCode debugger having issues with character encoding)
  2. Disable pretty-printing (Cannot see any variable values while debugging)

Upvotes: 0

Robscot75
Robscot75

Reputation: 91

I re-installed using the 64bit version of MinGW from sourceforge as I had an old 32 bit version running via mingw-get.

Upvotes: 3

Related Questions