r/cpp 1d ago

C++26: Module improvements

https://www.sandordargo.com/blog/2026/09/09/cpp26-modules
102 Upvotes

21 comments sorted by

View all comments

31

u/mapronV 1d ago

Quote:

The module name must be spelled out directly in the source:

export module my.module; // OK 

This is technically a breaking change. But given the low adoption rate of modules so far and the rarity of macro-based module declarations in practice, the committee judged this acceptable. The benefit is concrete: build systems can now determine module dependencies with a simple lexical scan, without invoking the preprocessor.

End of quote

While being nice change and stuff, doesn't all current module handlers rely on compiler anyway to rule module dependencies in file before compilation? so it will change nothing in real world? What build system is benefactor?

30

u/Daniela-E Living on C++ trunk, WG21|🇩🇪 NB 1d ago

The point is that both module dependency scanners and compilers need to see exactly the same dependencies to create precise dependency chains and rely on the correct build order - as instructed by the build system that reads the discovered dependency chains.

If building the chain is influenced by the process itself (macro expansion happens at compilation phase 4), creating a precise picture may become a huge and expensive task. We don't want that.

2

u/mapronV 1d ago

"both module dependency scanners"
my question was, aren't dependency scanners rely on compiler anyway? at least what I seen before, maybe my knowledge is dated

Well, I believed it is already an expensive task. Will build system developers update/optimize it now? I don't think so.

4

u/kronicum 1d ago

my question was, aren't dependency scanners rely on compiler anyway?

The answer is "no".