So, you want to use C++ Modules ... cross-platform? - Daniela Engert - NDC TechTown 2023

Discover how to use C++ Modules across platforms, including file sets, module translation units, private module fragments, and dependency scanning.

Key takeaways
  • We have named modules and global modules.
  • C++ modules are broken due to lack of agreement among implementers.
  • The module keyword can be used to declare a module, which can have a primary module interface or a global module fragment.
  • Inline namespace is recommended for interfaces.
  • Modules have file sets with BMI files.
  • Each module translation unit can have a leading section with a distinctive file extension (e.g., .cppm for Clang).
  • Private module fragments can be used to hide implementation details.
  • Modules can be used in a cross-platform manner with CMake, but header units are not yet supported.
  • The module keyword is required to create a named module, while global modules do not have a name.
  • Named modules have full isolation and no other stuff can change the meaning of entities within them.
  • The compiler checks for consistency between the primary module interface and the global module fragment.
  • Dependency scanning is required for modules.
  • Clang 17 supports experimental support for modules, while GCC requires an UUID to opt-in.
  • Header units are not supported in CMake.
  • CMake creates BMI files to manage dependencies.
  • The standard library can be used as a module with Clang.
  • Modules can be used with Linux, Windows, and macOS.
  • The demo code includes a modularized standard library, the arc pass library, and a file with a module declaration.