CMake officially supports C++20 modules

C++ 20 named modules are now supported in CMake 3.28 and newer when using Ninja and Visual Studio Generators (VS 2022 and newer in combination with the MSVC 14.34 toolset, provided with VS 17.4, and newer), LLVM/Clang 16.0 and newer, and GCC 14 (after the 2023-09-20 daily bump) and newer.
Last edited on

I guess it might be time to make the swap. I'll have to study up again.
From my admittedly limited experience Visual Studio and WinAPI C/C++ code compiled for x86 as C++ module code has "problems." Tell the IDE to compile as C/C++ code and the whinging goes away.

C/C++ code compiled for x64 processes the code as C++ modules just fine.

Go figure.
One of the easiest ways to use modules: just change the #include to import and add a ; to the end of the library file. There are some differences between #includes and imports and how they are handled. #includes can be chained in multiple header files, for instance. importing modules don't seem to chain-up.
Registered users can post here. Sign in or register to post.