C++C++ Explainer
C++ · 7 · Advanced / Job-Ready35 / 36 · 97%

Modules, ABI & Build Tooling

C++20 modules replace headers — and the rest of a professional build.

Examples: export module, CMake, sanitizers, clang-tidy

shortcuts: ← prev · → next · M mark
1

A Module

Compiled once, imported instantly — no textual inclusion.

Example
example
// math.ixx
export module math;

export int add(int a, int b) { return a + b; }
int helper() { return 0; }        // not exported

// main.cpp
import math;
int main() { return add(2, 3); }
2

Why Modules Win

Headers are re-parsed in every translation unit.

Headers
propertybehaviour
parsingonce per TU
macrosleak in and out
orderinclude order matters
guardsmanual
→
Modules
propertybehaviour
parsingonce, total
macrosisolated
orderirrelevant
guardsunnecessary
3

CMake for C++20

A modern, warnings-clean, sanitized build.

Example
CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
project(app CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(app main.cpp)
target_compile_options(app PRIVATE -Wall -Wextra -Wpedantic)

# debug builds with sanitizers
target_compile_options(app PRIVATE
    $<$<CONFIG:Debug>:-fsanitize=address,undefined -g>)
target_link_options(app PRIVATE
    $<$<CONFIG:Debug>:-fsanitize=address,undefined>)
4

Toolchain Checklist

What a production C++ repo runs in CI.

Complexity
ASan / UBSanmemory + UB bugsdebug + CI
TSandata races
clang-tidystatic analysis
clang-formatconsistent style
Catch2 / GoogleTestunit tests
vcpkg / Conandependency management