Boilerplate for C projects using MinGW in Visual Studio Code.
- Clone repo OR copy
.vscode
andsrc
directories into project - Install the C/C++ for Visual Studio Code extension
- Open any source file within the
src
directory and useCtrl + Shift + B
to build orCtrl + F5
to run in debugger - (Optional) Delete the file
bin/binaries_go_here
and lines 4-5 in.gitignore
, they are no longer needed
- Build settings are in
.vscode/tasks.json
- Debug settings are in
.vscode/launch.json
- By default, launching debugger will build project first - this can be changed by removing
"preLaunchTask": "build-project"
from.vscode/launch.json
- By default, an external console is opened when debugging. This can be changed by setting
"externalConsole"
tofalse
in.vscode/launch.json
- Custom command-line arguments for debugging can be set in
.vscode/launch.json
with the"args"
property - When creating new directories inside
src
containing source files (like in the case ofsrc/core/test.c
), make sure to include those source files in thebuild-project
task intasks.json
to avoid 'undefined reference' errors
- If you get the errors
'gcc' is not recognized as an internal or external command, operable program or batch file.
or'gdb' is not recognized as an internal or external command, operable program or batch file.
, make sure gcc and gdb are added to your PATH. Alternatively, you can specify the exact path to your compiler and debugger of choice instead within.vscode/tasks.json
.