Skip to content

niloydatta000/c-cpp-auto-compile-on-vscodes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ› οΈ C and C++ Smart Build Setup for VS Code (Windows)

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.


πŸ“Œ Purpose

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 and g++ for .cpp files.
  • Supporting both debug and release modes.
  • Enabling smooth debugging via GDB.
  • Helping users focus on coding rather than configuration.

πŸ“‚ What's Included?

  • βœ… 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 and main.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.


πŸš€ Quick Start

  1. βœ… Make sure gcc, g++, and gdb are installed (e.g., via MSYS2).
  2. βœ… Clone this repository.
  3. βœ… Open the folder in VS Code.
  4. βœ… Hit Ctrl+Shift+B to compile in debug mode or run Smart Build (Release) from the task list.
  5. βœ… Press F5 to launch the debugger.

πŸ“‹ Compiler Check

Run these in terminal to confirm compiler availability:

gcc --version
g++ --version
gdb --version

🧰 Customize or Reuse

Want to use this setup in all future projects?

  1. Move smart_build.ps1 to a global location like C:\scripts\smart_build.ps1.
  2. Update the path in .vscode/tasks.json.
  3. Copy the .vscode folder into new projects.

πŸ“Ž Reference

Installation guide: freeCodeCamp - How to Install C and C++ Compiler on Windows

About

Compiler Toggoler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published