Home > Net >  Breaking a module into multiple implementation files
Breaking a module into multiple implementation files

Time:06-14

C 20 modules question.

Let's say I have the following code files, where '.ixx' are module files.

Main.cc, A.ixx, B.ixx, ..., Z.ixx, Group.ixx

If I want to make all the files [A-Z] part of the same module, 'TheModule', does each file need a unique module partition name? ie:

// A.ixx
export module TheModule:A

// B.ixx
export module TheModule:B

// ...

// Z.ixx
export module TheModule:Z

// Group.ixx
export module TheModule;
export import :A;
export import :B;
// ...
export import :Z;

Is there a way for '.ixx' files to declare their stuff into 'TheModule', without each needing to have a separate partition name? And if so, how would importing work between the various '.ixx' files -- how do I access the stuff from 'A.ixx' within 'B.ixx'?

CodePudding user response:

If I want to make all the files [A-Z] part of the same module, 'TheModule', does each file need a unique module partition name?

Yes. Any module unit that can be independently imported either is the primary module interface unit or is a module partition. In both cases, it must have a name. A unique name.

Is there a way for '.ixx' files to declare their stuff into 'TheModule', without each needing to have a separate partition name?

No. Module includes represent a directed, acyclic graph of dependencies between files, not a hodge-podge collection of code.

  • Related