cppreference gives an example of a module partition implementation unit (A-C.cpp) being used without having to define a interface unit alongside it:
/////// A-B.cpp
export module A:B;
...
/////// A-C.cpp
module A:C;
...
/////// A.cpp
export module A;
import :C;
export import :B;
...
However, in my code - compiled with MSVC - the first example works, but the second doesn't:
/////// game.ixx
export module game;
import :rendering;
...
/////// rendering.ixx
export module game:rendering; // this works
...
vs
/////// game.ixx
export module game;
import :rendering;
...
/////// rendering.cpp
module game:rendering; // this doesn't work
...
From what I understand, removing the export
declaration in rendering.ixx
(and changing the extension back to .cpp
for MSVC, but I tried both) turns that partition into a implementation unit, which is something I want to do because I want to keep my rendering functions internal. However, I get a "module partition 'rendering' for module unit 'game' was not found
" error when I do that.
(Also, this is tangential but why doesn't game.ixx
throw an error because I didn't export-import the :rendering
partition in game.ixx
? cppreference says:)
Module partitions can be module interface units (when their module declarations have export). They must be export-imported by the primary module interface unit, and their exported statements will be visible when the module is imported.