VS Code C++ Debugger

Hi guys, i’m starting to get into VSCode and I’m trying to debug cpp/c files but when I enter into the debugging console the console just closes after I press enter (i’m just doing a simple code of adding a number that I scan in a loop) , obviously I’m not running without debugging (ctrl+f5) but with debugging (f5)

I have Mingw installed, gcc added to my path and obviously VsCode too.

I have this as launch.json file

{
    // 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": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        },
        {
            "name": "(Windows) Attach",
            "type": "cppvsdbg",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
        
    ]
    
}

As c_cpp_properties.json i have

{
    "configurations": [
        {
            "name": "Win32",
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true
            },
            "includePath": [
                "${workspaceFolder}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x86"
        }
    ],
    "version": 4
}

And as tasks.json this code

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Generated task by Debugger"
        }
    ]
}

So i don’t really understand what’s the problem, what i also have are these warnings(?) in the debug console but I’m trying to search this in google but nothing has helped me

-------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Loaded 'D:\C C++\tempCodeRunnerFile.exe'. Module was built without symbols.
Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
Loaded 'C:\Windows\SysWOW64\apphelp.dll'. Cannot find or open the PDB file.
Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
The thread 11832 has exited with code 0 (0x0).
The thread 13016 has exited with code 0 (0x0).
The program '[11612] tempCodeRunnerFile.exe' has exited with code 0 (0x0).

Any help would be great!!!

Not 100% certain as I’m unfamiliar with VSCode but …

Invoking your .exe won’t fire the debugger. You need to invoke the debugger. So try some sort of mod to your launch.json, you need to execute GDB like so:

gdb ${fileDirname}\${fileBasenameNoExtension}.exe

It might mean setting the “program” to “gdb” and the args to the .exe name.

Whoops, this suggests there is another magic setting in launch.json.