Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Breaking a module into multiple implementation files

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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’?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading