r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Apr 15 '26
How a Module Should Look Like
https://abuehl.github.io/2026/04/14/how-a-module-should-look-like.htmlThis illustrates the point using real code examples from the Core module of our UML Editor. The presented source code of our Core module is complete.
All published source code examples in the text or linked from it are 100% standard conformant. However, the code contains redundant imports. On purpose. Read the text for why!
(See also my previous posting "Let's bite the Bullet: Module Units shouldn't implicitly import anything" for context).
33
Upvotes
10
u/pavel_v Apr 15 '26
IMO, this is really hard to spot and at the same time it can have impact on the build times in some cases, if missing.
Do you know what is the reasoning behind the "implicit imports"?
Does the standard envision some particular organization of the files of a given module so that these "implicit imports" don't have negative impact on the build times in practice?
4
u/marssaxman Apr 15 '26
The title should decide whether it wants to be "How a Module Should Look" or "What a Module Should Look Like" and stop trying to be both at once...
5
u/germandiago Apr 15 '26
Makes sense to me even if it is ugly. In fact, explicit should have been the default. I think implicit can be more ergonomic but... you lose control and recompilations are introduced as mentioned in the article, so there should be a escape hatch for that.
Welcome addition, I guess. Wondering if the recompilation can be avoided nowadays or this is just impossible, given the bookkeeping of the information done by build systems.
Is this feasible now? It is difficult to implement? Or it is just plain impossible to solve?
5
u/_Noreturn Apr 15 '26
I appreciate your articles even though I don't use modules and hate them
1
u/tartaruga232 MSVC user, r/cpp_modules Apr 17 '26
See also my new blog posting "Thoughts About Changing the C++ Standard: Removing Implicit Imports".
1
u/kammce WG21 | πΊπ² NB | Boost | Exceptions Apr 15 '26
I think I asked a similar question on your previous post, but after reading this post I'll ask again with better insight.
Since the issue has to do with importing the core module, what if your main module is just the aggregate of partitions and you never made implementations for the module M.
And then the impl
This would force you to have to import the partitions that you need and also doesn't have the recompilation issue as before, right? And if so, then the consequence of doing this is a BMI for every partition. Do additonal BMIs result in slower compilation?