r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Apr 04 '26
Options for Organizing Partitions
https://abuehl.github.io/2026/04/04/options-for-organizing-partitions.htmlI'm looking forward to getting grilled. Thanks in advance for your time and your patience!
11
Upvotes
6
u/tartaruga232 MSVC user, r/cpp_modules Apr 05 '26 edited Apr 08 '26
We will for now use option 2.
If the C++ standard manages to adopt a better solution for option 2, we will adopt it. This could for example be the previously discussed:
5
u/GabrielDosReis Apr 05 '26
A tragedy around this whole "internal module partition" thing is that its semantic effects could be had without the standards introducing the asymmetry and taking away syntactic space from a better and more useful feature.
The primary motivation for internal module partition is ability for a component to "share some code" between its translation unit. That could already be had with a module interface partition that does not export any of its functions or types. E.g. if you have
importing the partition
Pin other module units will make all the declarations with module linkage in that other module unit, hence achieving the semantic effects desired.That would free up the syntax for module partition implementation unit, without adding more clutter.
0
u/tartaruga232 MSVC user, r/cpp_modules Apr 06 '26 edited Apr 06 '26
I appreciate having module partitions, but the user experience is pretty poor (to use diplomatic wording).
If I have an external partion, the standard tells me, that I have to export it from the primary module interface unit (PMIU). If I don't do that, my program is ill-formed. But compilers are not required to inform me about that ("no diagnostic required").
What a nice foot gun.
So probably because the compilers are unable to implicitly export the interface partitions themselves in the PMIU, I have to do that manually myself.
If I fail to do that, the compiler won't tell me.
To me the wording in the standard even looks like compilers are allowed to assume, that an external partion unit has been exported in the PMIU, if they see the keyword "export" followed by the "module" keyword (and the TU is a partition) and then apply heuristics about reachability.
There are moments, where I seriously think about going back to using header files.