This repository provides a ready-to-use automated build system for beginners and intermediate users of C and C++ in Visual Studio Code on Windows. It smartly detects file types, applies appropriate compilers, and offers debug/release build modes, all configurable through PowerShell and VS Code's tasks.json
.
Many C/C++ learners struggle to configure compilers or toggle between C and C++ projects in VS Code. This repo simplifies that process by:
- Automatically selecting
gcc
for.c
files andg++
for.cpp
files. - Supporting both debug and release modes.
- Enabling smooth debugging via GDB.
- Helping users focus on coding rather than configuration.
- ✅
smart_build.ps1
: A PowerShell script that intelligently compiles based on file type and build mode. - ✅
.vscode/tasks.json
: Pre-configured tasks for building in debug or release. - ✅
.vscode/launch.json
: A GDB-based debugging setup for MSYS2 users. - ✅
main.c
andmain.cpp
: Classic "Hello, World" examples for both languages.
All files are bundled for convenience so programmers can start writing and running C/C++ code immediately without setup headaches.
- ✅ Make sure
gcc
,g++
, andgdb
are installed (e.g., via MSYS2). - ✅ Clone this repository.
- ✅ Open the folder in VS Code.
- ✅ Hit
Ctrl+Shift+B
to compile in debug mode or run Smart Build (Release) from the task list. - ✅ Press
F5
to launch the debugger.
Run these in terminal to confirm compiler availability:
gcc --version
g++ --version
gdb --version
Want to use this setup in all future projects?
- Move
smart_build.ps1
to a global location likeC:\scripts\smart_build.ps1
. - Update the path in
.vscode/tasks.json
. - Copy the
.vscode
folder into new projects.
Installation guide: freeCodeCamp - How to Install C and C++ Compiler on Windows