r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Apr 13 '26
Let's bite the Bullet: Module Units shouldn't implicitly import anything
https://github.com/abuehl/docs/blob/main/no-implicit-import.mdThe correct fix ... is to attack the root cause and stop implicitly importing the interface of module implementation units.
Adding yet another kind of partition is the wrong way to solve it.
19
Upvotes
View all comments
Show parent comment
4
u/tartaruga232 MSVC user, r/cpp_modules Apr 13 '26
If you are referring to (quote from my document):
Then I think the answer to your question is: No.
The sole purpose of these "internal partitions" is, that they implement some functions of module
M, which are then linked into the*.exe. The only thing we need is, that these functions are "attached" to moduleM. The symbols cannot clash with any symbol from a different module. To the linker, these are private symbols.To do that, TU 6 and 7 import only the declarations from
:P1. Because only these declarations are needed there.When compiling TU #6, the compiler produces a
*.obj, containing the compiled code for the functions that were defined in TU #6. It also produces a BMI. The BMI is unused and unwanted, but I think we can't avoid that. Because the intention of internal partitions normally is, that they provide declarations for use in other parts of the same module. But TU #6 and TU #7 are not used for that purpose. They aren't imported anywhere.Like I said in my document:
Partitions do not implicitly import anything. That's the reason for using them there.
You wrote:
Partitions aren't modules. They are module units. They are parts of a module.
See also https://abuehl.github.io/2026/04/09/internal-partitions.html