Are We Macro-free Yet?
summary
Describes removing macros from a C++17 codebase by replacing conditional compilation with compile-time booleans (e.g. has_blast variable), moving implementation choices into a pimpl + dependency inversion layer, and using immediate lambdas and context-sensitive constexpr to avoid #ifdef-driven interfaces. Builds a macro-free logging replacement using C++20 formatting and lazy evaluation, and parameterizes tests across backends with doctest parameterized tests. Result: code compiles with optional toolchains (CUDA) via shared headers, no build-time slowdown, and higher confidence in correctness.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:22Why eliminate macros
- 6:55Problems with conditional compilation
- 10:03If-constexpr as alternative
- 14:15Replacing macro replacements
- 22:33Dependency inversion principle
- 33:12Macros from third-party libraries
- 39:04Strategy to remove macros
- 45:12Q&A
related talks
13mTowards Macro-Aware C-to-Rust Transpilation (WIP)
01h 32mDeveloping Better C++ Code by Isolating Decisions
01h 03mApplied Best Practices
01h 00m“Constexpr Everything” - The Standard Library, Microkernel, Apps, and Unit Tests
01h 01mEasy to Use, Hard to Misuse: Declarative Style in C++
15mVerification of Templated Code in C++
01h 24mKeynote: Optimizing for Change
01h 01m“Mocking Frameworks considered harmful”
