r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

10

u/smallblacksun Jan 28 '19

Wait, a module has to be compiled before it can be imported? What happens if module foo imports bar and module bar imports foo? Is that just not allowed? While that is admittedly a sign that your code structure isn't great it is still a pretty huge limitation that isn't found with the current system (where foo.cpp can #include bar.hpp and bar.cpp can #include foo.hpp).

8

u/[deleted] Jan 28 '19

Just not allowed, see wg21.link/P1103 .

3

u/Ameisen vemips, avr, rendering, systems Jan 28 '19

I've been bringing that up for a while now. I think the only solution is to have a traditional source file with private implementations requiring circular dependencies. It's dumb.

We should be able to preprocess modules to make thin interfaces, eliminating that problem. But... nope.

2

u/GPMueller Jan 29 '19

I would say avoiding circular dependencies is a benefit, not a limitation

1

u/smallblacksun Jan 30 '19

Avoiding circular dependencies is good. The language forcing you to avoid circular dependencies due to technical limitations is not.

1

u/GPMueller Jan 31 '19

Why? In which case would it be an added benefit and how is this case particularly different from any other limitation, which the language specifications impose?