Using a linux machine to write c code makes the process a little bit easier because the c compiler and debugger probably are already installed.
To be able to debug c code it is necessary to compile the code with the necessary parameters, for example:
gcc -g hello.c
After that, you need the appropriate configuration on your launch.json file:
{
"name": "Debug c",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
This is the most basic configuration. If you change the output name during compilation, don’t forget to change it on the file too.
Top comments (0)