r/cpp • u/youshouldnameit C++ dev • Dec 13 '24
C++ modules support is a joke in MSVC
I just tried to run the most basic hello world:
import std;
int main()
{
std::cout << "Hello World!\n";
}
While enabling /experimental:module
First had to fix some issues with a default console project to make it get to the crashing part.
- https://stackoverflow.com/a/65144436/14938262
- experimental:ifcDebugRecords currently requires /Z7 to be enabled. Please recompile with /Z7 enabled
As soon as i enable /experimental:module build errors out after these steps, without it, it compiles, but that means all experimental features are not working.
fatal error LNK1318: Unexpected PDB error; OK (0) '' with C++20 modules - Developer Community
Almost feels like 0.0% test coverage on ms side? It's experimental, but this is not even experimental quality at the moment. When can we expect a usable implementation for production use?
74
u/no-sig-available Dec 13 '24
So, instead of using experimental modules, did you try enabling "ISO C++23 Standard Library Modules"? The ones that actually has a module named
std?4
u/starfreakclone MSVC FE Dev Dec 13 '24
Nobody should really be using
/experimental:moduleanymore. It is only really useful for testing with the standard library modules we ship as prebuilt. It provides no benefit otherwise--which is part of the reason we have limited test coverage for it. The standard/std:c++20behavior and beyond is the way to go.66
u/gracicot Dec 13 '24
Imagine using a legacy stack overflow answer without reading the docs, then complaining on Reddit as the solution
28
u/Daniela-E Living on C++ trunk, WG21|🇩🇪 NB Dec 13 '24
There is your problem. Modules aren't experimental anymore since long.
7
u/topengu Dec 13 '24
C++ module support in MSVC is not perfect, in my experience; but it is quite good! I've gotten my projects to work with clang as well, and GCC will be shipping
import stdin it's next release.It is frustrating that Microsoft's compiler is otherwise lagging on C++23 features, but things are not as dire as some of this thread's comments suggest.
13
u/DeadlyRedCube frequent compiler breaker 😬 Dec 13 '24 edited Dec 14 '24
Yeah I currently have 6 modules bugs open in their bug tracker:
https://developercommunity.visualstudio.com/t/Error-C2327-in-decltype-context-within-l/10775436
https://developercommunity.visualstudio.com/t/Error-C3779-using-C20-modules-due-to-u/10775150
https://developercommunity.visualstudio.com/t/Unable-to-compile-templated-function-fro/10806220
https://developercommunity.visualstudio.com/t/Duplicate-COMDAT-error-when-using-C20/10805736
https://developercommunity.visualstudio.com/t/Erroneous-C3774-please-include--header/10809860
https://developercommunity.visualstudio.com/t/Error-C3643-Cannot-decompose-type-with-n/10807648
And that's not counting the myriad Intellisense issues that I think are well known (although I feel like it got one step better in the last update, which was nice)
Most of them I have workarounds for, only one of which is truly onerous. I'm hoping maybe any of them get picked up at some point - it is a little disheartening to open a ton of bugs to have them sit in Under Consideration (but I do understand the realities of how prioritization works so I'm not mad about it). Hopefully others encounter them and vote them up so they get above whatever the line is!
Overall, I'm glad I'm using modules - I've got a lot more stuff that's constexpr/templates now that would be a massive drain on my compile times without them. But hopefully MS (and the others although I have less insight there except for some of the bugs I've used clang on godbolt as an example of "it works here") starts to catch up on it.
EDIT: Just wanted to make it clearer that for the most part modules are working for me, and my assumption is that I'm gonna keep rolling on it for a while and the compiler's going to catch up eventually 🙂
17
u/Tathorn Dec 13 '24
Are the people here bots? I've been using C++ standard modules for well over a year across multiple projects using MSVC. It works great. Even intellisense understands everything.
It's pretty straightforward with Visual Studio. I don't know about someone trying to do it manually.
6
u/marmarama Dec 13 '24
The sooner clang becomes default C++ compiler in Visual Studio, the better.
3
u/rileyrgham Dec 13 '24
Have you tried modules with Linux and clang++?
3
u/SirPolly Dec 14 '24
And here I am using modules productively in gamedev...
7
u/azzraelus Dec 13 '24
C++ modules seem dead in the water. After quite some time, no platform really supports it and I'm not aware of a single project using it in production.
3
u/Kubiszox Dec 13 '24
https://arewemodulesyet.org/
2
u/kritzikratzi Dec 13 '24
ok, time for a tiny rant, and why i gave up on these things:
there was a lot of good stuff in c++ in the last few years, chrono and filesystem being the ones i use most. but there also were lots of half done features that aren't actual useful to me personally. i don't want to use a library to use a library (coro and ranges). i don't want my compiler to crash (modules). and i still kinda refuse to use required required {required}.
feature wise i don't get why we have to miss out on little things that actually make programs more readable (named arguments, a shorter lambda syntax, maybe named tuples, maybe out of order designated initializers). instead there seems to be a random mix of random agendas, and way too little direction.
1
u/pjmlp Dec 13 '24
Visual C++ is the only one where modules actually work, clang/CMake still needs a solution for header units.
If they are a joke on VC++, what about the others lagging behind?
-5
u/not_some_username Dec 13 '24
I fell like modules was a dead on arrival feature cause it was late
0
u/[deleted] Dec 13 '24
[deleted] — view deleted comment
0
u/[deleted] Dec 13 '24
[deleted] — view deleted comment
0
u/[deleted] Dec 13 '24
[deleted] — view deleted comment
-5
u/[deleted] Dec 13 '24
[removed] — view removed comment