What are C++20 Modules, and how do they fundamentally change the compilation model compared to header files?

Last updated 21 June 2026

  • Headers are textual: #include pastes and re-parses the header in every translation unit, leaks macros, and needs include guards.

  • A module (export module M;) is compiled once into a binary interface that consumers import. Only exported names are visible and macros don't leak, giving faster builds and order-independent imports.

  • Caveat: toolchain and build-system support is still maturing, and module interfaces impose build ordering dependencies.

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions