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.cppwith comments explaining active-file execution.vscode/tasks.jsonthat compiles${file}.vscode/launch.jsonusing CodeLLDB.vscode/settings.jsonthat opens the Debug Console and avoids unwanted assembly views- Immediate
std::coutflushing 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
- macOS:
- Run C++ Active File: Create Cross-Platform C++ Debug Project.
- Open a
.cppfile and pressF5.
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.
Publishing
See PUBLISHING.md for Marketplace instructions.