Why do all compilers use the strong ownership model for C++20 modules, instead of the weak model?

1 day ago 9

In short, the strong ownership model = all functions declared in a module are mangled to include the module name, while the weak ownership model = only non-exported functions are mangled this way.

All three big compilers seem to use the strong model (with extern "C++" as a way to opt out). But why?

I asked on stackoverflow, but didn't get a satisfying answer. I'm told the weak model is "fragile", but what is fragile about it?

The weak model seems to have the obvious advantage of decoupling the use of modules from ABI (the library can be built internally with or without modules, and then independently consumed with or without modules).

The strong model displays the module name in "undefined reference" errors, but it's not very useful, since arguably the module name should match the namespace name in most cases.

Also the strong model doesn't diagnose duplicate definitions across modules until you import them both in the same TU (and actually try to call the offending function).

Does anyone have any insight about this?

submitted by /u/holyblackcat to r/cpp
[link] [comments]
Read Entire Article