r/cpp • MSVC Game Dev PM • Sep 14 '20

Standard C++20 Modules support with MSVC in Visual Studio 2019 version 16.8 | C++ Team Blog

https://devblogs.microsoft.com/cppblog/standard-c20-modules-support-with-msvc-in-visual-studio-2019-version-16-8/
254 Upvotes

128 comments sorted by

View all comments

Show parent comments

46

u/starfreakclone MSVC FE Dev Sep 15 '20

Hi Minimonium,

I am sorry you feel that the team at MS has violated the rules set out in the standard. As /u/GabrielDosReis mentions, the IS today allows for such a model so the decision was made, collectively by the toolset team, to support the strong ownership model. The strong ownership model really should be preferred for the purposes of hardening library code and truly isolating entity definitions.

As far as addressing your concern about writing portable code across clang/gcc/MSVC: there is still an avenue for this. The MSVC toolset does still implement the weak ownership model, though it is not on by default. Projects wishing to use the weaker form will get the usual linker errors which surface in the example from the blog.

> If you write code for the weak model it might fail to compile on the strong model

Can you elaborate on this? It is not obvious to me how this can happen.

-5

u/Minimonium Sep 15 '20

I don't have any objections regarding Microsoft's implementation of the standard's rules, you can double-check it in the part of my message where I voiced my concern starting with "Because the IS allowed both...". I don't need you to "sell" me the strong ownership, I too see more the benefits in it especially on the scale of dynamic dependencies updates and I'm perfectly clear on existing practice on it. The issue is that it's not mandated, but just allowed.

As the language is concerned, the whole weak vs strong debate is completely irrelevant. The only difference in how they treat IFNDR. But it's exactly the issue when you think about portability in practice.

As the story about visible symbols in shared libraries has shown us - it doesn't matter if you provide both behaviours, really. The one that's the default will be the one relied on their respective platforms - the culture clash is there when you try to convince a group of Linux developers to adopt the visibility(hidden).

I'm not concerned about projects avoiding the IFNDR problem altogether under either of the models, I'm concerned about projects relying on it which would be the __cxx11 problem of the next decade.

The weak model allows relying on the forward declaration IFNDR. In the strong model, you'll get a link error in this case.

And again, I don't argue over whose implementation is right or wrong. I argue that to keep at least the basic level of technical integrity - one absolutely should not state the ownership model as a matter of fact in the design of the modules, there is no even private consensus across implementors, it's dishonest to imply it in the discussions.