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
gccfor.cfiles andg++for.cppfiles. - 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.candmain.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++, andgdbare installed (e.g., via MSYS2). - β Clone this repository.
- β Open the folder in VS Code.
- β
Hit
Ctrl+Shift+Bto compile in debug mode or run Smart Build (Release) from the task list. - β
Press
F5to launch the debugger.
Run these in terminal to confirm compiler availability:
gcc --version
g++ --version
gdb --versionWant to use this setup in all future projects?
- Move
smart_build.ps1to a global location likeC:\scripts\smart_build.ps1. - Update the path in
.vscode/tasks.json. - Copy the
.vscodefolder into new projects.
Installation guide: freeCodeCamp - How to Install C and C++ Compiler on Windows