c++visual-studio-code

VS Code C++ unnecessary debugging steps


I recently started learning C++ with VS Code and when I run any program (not debugging, just run) I get two tabs in terminal - one for build output and the other as some sort of debugging as I get from the cppdbg written there

Build output

Debugging

none of this happen when I execute the program directly from terminal and not even in the tutorial videos I am learning from. It started happening when I got the preLaunch gcc.exe error when I ran the program for the first time, after which I deleted the .vscode folder and chose the compiler while going to run it again, as I saw here

I am not sure why does it happen and if I can get the usual run commands there


Solution

  • This is controlled by the console option in the launch.json file.

    On Windows with externalConsole: false and console: internalConsole it will not create a new terminal but uses the existing one.

    FMI: https://code.visualstudio.com/docs/cpp/launch-json-reference#_externalconsole

    "configurations": [
        {
            "name": "test",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/test.exe",
            "args": [
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/build/",
            "environment": [],
            "console": "internalConsole",
            "externalConsole": false,
        },