Lesson plan
Modules (C++)
Modules in C++ are a feature added in C++20 implementing modular programming as a modern alternative to precompiled headers. A module in C++ comprises a single translation unit. Like header files and implementation files, a module can contain declarations and definitions, but differ from precompiled headers in that they do not require the preprocessor directive #include , but rather are accessed using the keyword import . A module must be declared using the keyword module to indicate that the translation unit is a module. A module, once compiled, is stored as a built module interface (BMI) file which behaves similarly to a (precompiled header) file. Module symbols and import s are resolved at the compilation stage, not the linking stage. Modules most commonly have the extension (primarily common within Clang and GCC toolchains), though some alternative extensions include and (more common in Microsoft/MSVC toolchains), or even the traditional C++ extension . Though the standard C language does not have modules, dialects of C allow for modules, such as Clang C. However, the syntax and semantics of Clang C modules differ from C++ modules significantly.
Article summary
Modules in C++ are a feature added in C++20 implementing modular programming as a modern alternative to precompiled headers. A module in C++ comprises a single translation unit. Like header files and implementation files, a module can contain declarations and definitions, but differ from precompiled headers in that they do not require the preprocessor directive #include , but rather are accessed using the keyword import . A module must be declared using the keyword module to indicate that the translation unit is a module. A module, once compiled, is stored as a built module interface (BMI) file which behaves similarly to a (precompiled header) file. Module symbols and import s are resolved at the compilation stage, not the linking stage. Modules most commonly have the extension (primarily common within Clang and GCC toolchains), though some alternative extensions include and (more common in Microsoft/MSVC toolchains), or even the traditional C++ extension . Though the standard C language does not have modules, dialects of C allow for modules, such as Clang C. However, the syntax and semantics of Clang C modules differ from C++ modules significantly.
Key claims
No claims recorded.
Discussion questions
- Summarise the article in your own words. Which single claim would you verify first, and why?
- Which claim in this article is most likely to be revised as the sources update? How would you check its current status?
- If two sources disagreed about one of these facts, what would you need in order to trust one over the other?
Bibliography
No sources recorded.
Key claims and bibliography are generated from the same tracked claims and sources as the article page.