r/cpp • cmake dev • Jun 01 '26

BMI Compatibility: Testing Build System C++ Modules Support

https://blog.vito.nyc/posts/bmi-compatibility/
68 Upvotes

43 comments sorted by

View all comments

Show parent comment

3

u/tartaruga232 MSVC user, r/cpp_modules Jun 02 '26

Module units mix the semantics of implementation units and headers, definitions and declarations, into a single file. You can artificially separate them if you want, and there are advantages to doing so, but it is no longer necessary.

Indeed.

We're now combining a lot of module interface units and implementation units into a single module unit each, which has both the interface and the implementation in the same file, separated by a private module fragment declaration ("module : private;" / example: https://github.com/cadifra/cadifra/blob/main/code/WinUtil/Dispatcher.ixx). The advantage of doing that is, that the compiler needs to read only one file and it produces the BMI and the obj in one go.

Doing that is sometimes not possible if you get import cycles or the dependencies are too heavy. Then you have to use the classical interface / implementation file split.

Small modules support this kind of combined interface / implementation style pretty well.