I searched for a solution for a week but couldn't solve this one without posting here.
I'm coding in C in Vs code and I had no issues so far (on a laptop). Few days ago debugging suddenly stopped working; this is how is goes: simple code like:
#include <stdio.h>
int main(){
int x;
x=1;
x*=10;
printf("\ntest %d",x);
}
I press the green arrow play button to run it. I compiles and builds fine (as per task.json), but the breakpoint is not hit and also the "printf" does not get any result in the integrated terminal. Also the "debug console" shows nothing
This is my task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe compile active file",
"command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"isDefault": true,
"kind": "build",
},
"detail": "compiler: C:\\msys64\\mingw64\\bin\\gcc.exe"
}
]
}
and my launch.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": "gcc.exe - Compile and run debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Abilita la riformattazione per gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe compile active file"
}
]
}
I also tried and re-install everything Vs code, C/C++ Intellisense, Extention Run Code as well, unsitalled mingw and reintsalled it following the steps at "https://code.visualstudio.com/docs/cpp/config-mingw". But the "missing debug" behaviour persisted.
On the other hand if I manually run the test.exe in the integrated terminal (powewrshell) by simply typing ".\test.exe" it work fine.
any idea?, thanks
The accepeted answer was given by olyBlackCat in the comments, which I'm quoting here to mark it as the accepted answer:
I'm seeing a lot of questions like this. Maybe try this extension instead of the default C++ one? It works for me on Linux. – HolyBlackCat Aug 16 at 17:28
Found the bug report. There's some advice there github.com/microsoft/vscode-cpptools/issues/7971