Toolchain & Ecosystem
Compilers
GCC
g++ -std=c++23 -O2 -Wall -Wextra -Wpedantic main.cpp -o app
g++ -march=native # optimize for the host CPU micro-architecture
g++ -flto # link-time optimization
g++ -fsanitize=address,undefined # runtime checksBroadest platform coverage (embedded, Linux, cross-compilation); libstdc++ is the default standard library on Linux. GCC 13+ has essentially complete C++23 support.
Clang / LLVM
clang++ -std=c++23 -O2 main.cpp -o app
clang++ -flto=thin # ThinLTO — faster than full LTOFast compilation, best-in-class error messages, rich tooling ecosystem (clang-tidy, clang-format, clangd).
MSVC
cl /std:c++latest /O2 /W4 /EHsc main.cpp
cl /permissive- # strict standards conformance
cl /analyze # static analysisNative Windows support, high-quality STL implementation (ranges/format/modules), deep Visual Studio integration.
Intel oneAPI
icpx -std=c++23 -O2 -xHost main.cpp # auto-detect the latest SIMD instruction setDeepest optimization for Intel CPU micro-architectures; suited for HPC and scientific computing.
Build Systems
CMake (de facto standard)
cmake_minimum_required(VERSION 3.28)
project(MyApp LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_executable(app src/main.cpp)
target_compile_options(app PRIVATE -Wall -Wextra)
find_package(fmt REQUIRED)
target_link_libraries(app PRIVATE fmt::fmt)CMakePresets.json (3.19+) defines build types and toolchains, replacing manual -D options.
Meson
project('myapp', 'cpp',
default_options : ['cpp_std=c++23', 'warning_level=3'])
executable('app', 'src/main.cpp', dependencies : [dependency('fmt')])Concise syntax, fast build times — well suited for small-to-medium projects.
Bazel
Top choice for large monorepos: precise incremental builds (content hashing), remote caching, distributed builds, cross-language support.
Package Managers
vcpkg
{ "name": "myapp", "dependencies": ["fmt", "nlohmann-json"] }Tightest native integration with CMake; excellent Windows support.
Conan
conan install . --output-folder=build --build=missing
cmake -B build -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmakeCross-build-system support (CMake / Meson / MSBuild), large ConanCenter package registry, binary caching to speed up CI.
Sanitizers (Runtime Checks)
# ASan — memory errors (heap overflow / use-after-free / leaks / double-free)
g++ -fsanitize=address -fno-omit-frame-pointer -g main.cpp
# TSan — data races (5–15x overhead; cannot be combined with ASan)
g++ -fsanitize=thread -g main.cpp
# UBSan — undefined behavior (integer overflow / null pointer / array out-of-bounds)
g++ -fsanitize=undefined -g main.cpp
# Combined (recommended: always enable in CI)
g++ -fsanitize=address,undefined -fno-omit-frame-pointer -g -O1 main.cpp
ASAN_OPTIONS=detect_leaks=1 ./app
UBSAN_OPTIONS=print_stacktrace=1 ./appStatic Analyzers
clang-tidy
clang-tidy src/*.cpp -- -std=c++23 -Iinclude/Core check groups: bugprone-* (common bugs), modernize-* (modern C++), performance-* (performance), cppcoreguidelines-*.
PVS-Studio
Commercial-grade deep data-flow analysis with a low false-positive rate. Strong at analyzing complex templates and macro expansions.
SonarQube
General-purpose code-quality platform offering Quality Gates and technical debt tracking. Suited for team-level governance.
IDEs
| IDE | Highlights |
|---|---|
| Visual Studio | Top choice on Windows — IntelliSense, built-in debugger/profiler |
| CLion | Cross-platform, native CMake support, strong refactoring |
| VS Code + clangd | Lightweight and cross-platform, CMake Tools extension |
CI/CD for C++
name: C++ CI
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: cmake -B build
- run: cmake --build build --parallel
- run: ctest --test-dir build --output-on-failure
- name: Sanitizers
if: matrix.os == 'ubuntu-latest'
run: |
cmake -B build-san -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined"
cmake --build build-san && ctest --test-dir build-sanToolchain Selection
| Scenario | Recommendation |
|---|---|
| Linux server-side | GCC / Clang + CMake + vcpkg + ASan / TSan |
| Windows desktop | MSVC + Visual Studio + vcpkg |
| Cross-platform library | Clang + CMake + Conan + multi-compiler CI |
| HPC / Scientific computing | Intel oneAPI + CMake + Spack |
| Large monorepo | Bazel + remote caching |
Key takeaway: set up a CI pipeline as early as possible — compile errors, test failures, sanitizer reports, and static-analysis warnings caught during the PR stage are far cheaper to fix than debugging them in production.