Modules (since C++20)

Most C++ projects use multiple translation units, and so they need to share declarations and definitions across those units. The usage of headers is prominent for this purpose, an example being the standard library whose declarations can be provided by including the corresponding header.

# Notes

Feature-test macro Value Std Feature __cpp_modules 201907L (C++20) Modules — core language support __cpp_lib_modules 202207L (C++23) Standard library modules std and std.compat

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 2732C++20it was unclear whether importable headers canreact to preprocessor state from the point of importno reaction
P3034R1C++20module names and module partitions couldcontain identifiers defined as object-like macrosprohibited