vs-code launch.json showing error for cpp debugger

Viewed 951

launch.json file for cpp debugging is showing error. help me to rectify it

{
    "version": "0.2.0",
    "configurations": [
      

      {
        "name": "g++.exe - Build and debug active file",
        "type": "by-gdb",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
      }
    ]
  }

It is showing 7 errors in it

Property args is not allowed.
Property stopAtEntry is not allowed.
Property environment is not allowed.
Property externalConsole is not allowed.
Property MIMode is not allowed.
Property miDebuggerPath is not allowed.
Property setupCommands is not allowed.
2 Answers

Change "type" to "cppdbg".

This isn't documented anywhere but half the extra debugging properties for C++ don't work if your type is not "ccpdbg" (if you're debugging gdb or lddb) or "cppvsdbg" if you're debugging with VS.

I ran into the same issue when using "type": "lldb".

I had this problem after I switched to WSL2.

I needed to install the popular "C/C++" extension for Visual Studio Code.

The extension was before only enabled for the local machine.

Related