r/cpp • • Mar 09 '26

The compilation procedure for C++20 modules

https://holyblackcat.github.io/blog/2026/03/09/compiling-modules.html
103 Upvotes

47 comments sorted by

View all comments

Show parent comment

3

u/holyblackcat Mar 10 '26

If both types are under your control, you could extern "C++" them to allow forward declarations. (And if they aren't both under your control, how are they referring to each other circularly. :P)

This isn't ideal, but seems workable.

2

u/kamrann_ Mar 11 '26

While true, I think if this was to be considered 'the solution' to such a situation then it would be an acknowledgement of a design failure of modules. It's basically a get-out clause for compatibility, where you're opting out of one of the core features - entities being attached to a named module.