Create a ready-to-debug, single-file C++ practice project from the VS Code Command Palette on macOS, Linux, or Windows.
What it creates
hello.cpp with comments explaining active-file execution
.vscode/tasks.json that compiles ${file}
.vscode/launch.json using CodeLLDB
.vscode/settings.json that opens the Debug Console and avoids unwanted assembly views
Immediate std::cout flushing so output remains visible before debugger stops
Compiler warnings on every supported platform
Undefined-behaviour sanitizer on macOS and Linux
Use
Install the extension.
Open an empty folder in VS Code.
Open the Command Palette:
macOS: Shift+Command+P
Windows/Linux: Ctrl+Shift+P
Run C++ Active File: Create Cross-Platform C++ Debug Project.
Open a .cpp file and press F5.
The active editor file is compiled because the build task uses ${file}. Switching to a different .cpp file before pressing F5 builds and runs that file instead.
Platform behaviour
Platform
Preferred compiler
Output
macOS
Apple Clang++
build/Debug/outDebug
Linux
G++, then Clang++
build/Debug/outDebug
Windows
MinGW G++, then LLVM Clang++
build\Debug\outDebug.exe
The extension detects an available compiler when possible and writes that command into the generated tasks.json.
Requirements
VS Code
CodeLLDB
Microsoft C/C++ extension
A C++ compiler available on PATH
CodeLLDB and Microsoft C/C++ are included in this extension's extension pack. Compilers must be installed separately.
Scope
This is a single-file learning template. The active .cpp file must contain main(). Multi-file applications should use a build system such as CMake.