r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Apr 21 '26
Uneeded Recompilations When Using Partitions
https://abuehl.github.io/2026/04/20/unneeded-recompilations-when-using-partitions.htmlThis blog posting from me about C++ modules explains in detail what causes unneeded recompilations using detailed code examples from the sources of our UML Editor.
It's a precise description and a showcase of what's the status quo in the C++ standard.
Quote from the posting:
The C++ language currently lacks a concise and easy to use alternative for explicitly expressing the minimally required dependencies on partitions.
(Note: All code examples shown or linked from the text are 100% standard conformant.)
Thanks in advance for comments. Please ask if you do not understand anything or anything is unclear. I would appreciate if you could leave a comment if you don't like anything. Thanks for reading!
9
u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions Apr 21 '26
I think I disagreed before, simply because there was a work around, but I think I'm convinced that the module implementation unit shouldn't implicitly import all partitions. It should just add itself to the module and let the user import which partitions they want. I would like to know more about the rationale behind this.
8
u/current_thread Apr 21 '26 edited Apr 21 '26
In my game engine I'm doing this and I don't have any undesirable compilation cascades:
I'd be curious for the designers of modules to come forward and explain the intention behind the choices better. Why the implicit imports? Why can't module interface partitions and module implementation partitions share a name? What would be the platonic/ideal way to use modules?
3
u/AdOnly69 Apr 21 '26
And there is no solution for this?
5
u/smdowney WG21, Text/Unicode SG, optional<T&> Apr 22 '26
It seems like you are trying to use partitions to do the job of modules? If you don't depend on the whole interface, then you have a cohesion problem telling you that you have more than one thing.
2
u/holyblackcat Apr 23 '26
I hope
module A:;or equivalent gets in.But to think of it, it should be possible to implement as an extension on the build system side, as
module A:_;. All we need is compiler flags to omit BMI generation (Clang already has that, in the form of-xc++).-2
u/NewLlama Apr 21 '26
You've been posting about this like every other day. We get it, you don't like modules.