I've started working with Visual Studio Code on Windows & I want to debug the following file
main.c (located at C:/Users/aibrakov/Projects/c directory):
#include <stdio.h>
int main(void) {
int x = 42; // add breakpoint here
printf("Hello World!\n");
getchar();
return 0;
}
Following this threads
- C\C++ in VS Code with Linux Subsystem For Windows
- Visual Studio Code and Bash on Ubuntu on Windows (WSL) GCC/GDB integration
I have
settings.json:
{
"window.zoomLevel": 0,
"terminal.integrated.shell.windows": "c:\\windows\\sysnative\\bash.exe"
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Build project",
"type": "shell",
"command": "gcc",
"args": [
"-g", "main.c"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "/mnt/c/Users/aibrakov/Projects/c/a.out",
"stopAtEntry": false,
"cwd": "/mnt/c/Users/aibrakov/Projects/c",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"pipeTransport": {
"pipeCwd": "",
"pipeProgram": "c:\\windows\\sysnative\\bash.exe",
"pipeArgs": [
"-c"
],
"debuggerPath": "/usr/bin/gdb"
},
"sourceFileMap": {
"/mnt/c": "c:\\"
}
}
]
}
Building project with Ctrl + Shift + B succeeds.
Debugging kinda works: it stops on breakpoints and DEBUG CONSOLE
tab is accessible, but I don't get output (Hello World!
in my example) and also can't send character which getchar
awaits.
Is there a way to work with the terminal in which my program is running? Or am I missing something?