MSVC: The Devourer of Const
ibob.bg
ibob.bg
https://developercommunity.visualstudio.com/t/wrong-type-of-...
The compiler ends up omitting most of the rest of the function's assembly, which breaks things as much as you'd expect. (For bonus fun, our ternary expression was deep under about four layers of macro.)
"return (cond)? result : throw;"
and it crashed the compiler. (It was an older version of MSVC.)
- 3 bugs marked as "Our teams prioritize action on product issues with broad customer impact" and never fixed
- 1 bug fixed
- 1 bug merged with another bug and fixed
The `Hero.{x,y}` properties here are a custom fixed precision number class with some implicit conversions to int, which I suspect being relevant to the crash.
[1] https://github.com/ArmageddonGames/ZQuestClassic/blob/e678e9...
I am currently working on a game + custom engine that is around 1M lines of C++ code. Thanks to pre-compiled headers and forward declarations, I can compile all of it in under 20 seconds (full rebuild, optimizations enabled).
AMD Ryzen 9 7950X 16-Core Processor All code is stored on an NVMe drive, Windows Defender realtime protection is disabled.
There's also a way to profile your build process with MSVC. It seems a bit daunting at first, but it's actually not that complicated: https://devblogs.microsoft.com/cppblog/introducing-c-build-i...
I don't know if it works with MSVC, but I think it should.
Also it uses the old style preprocessor by default which is not C++20 compatible, leading to writing a lot of very tricky macros in order to implement something that would otherwise be a couple of lines tops.
Lots of legacy choices are the default, you need to use lots of other C++ tools in order to get a more modern development environment.
The preprocessor mode can be manually changed trivially. Project Properties -> C/C++ -> Preprocessor -> Use Standard Confirming Preprocessor. And changing all of the other project properties are just as trivial (picking which C++ version you want, enabling/disabling language extensions, warning level, etc).
I'm not sure changing the project properties via MSVC's project property changer counts as having to use "lots of other C++ tools"...
As for changing properties in MSVC, the issue I had was that when creating a new solution it would create a x86 project by default. So I would have to go in and create a new x64 configuration, change the project properties for all projects, then remove the x86 configuration from the projects and solution. Though whenever I added a new project it would default to x86 and I would have to redo all of the configuration steps again and once more delete the x86 configuration from the solution. I even tried using props files to try and simplify this but it never worked well enough.
So for me it was much easier to learn how to use CMake properly, add the global settings to the top level CMakeLists.txt file, then a new project could be added by creating a new CMakeLists.txt file and rerunning CMake. There would be no need to mess around with the settings in the IDE worrying about if you forgot to update one or if the settings got out of sync.
It also depends how you write your code because there are many ways to reduce memory usage, for example switching to arrays and 32bit indexes instead of using native sized pointers. Can also use smaller data types than size_t etc.
Having both x64 and x86 as configurations by default is a step forward, but realistically I wouldn't want any configuration in my solution which does not work and is not supported.
I can’t see Microsoft abandoning their C++ compiler. The C++ compiler is a foundational technology for them and it’s something they want to own and control.
E.g. when they claimed concept support, it was not possible to use requires-expression outside of a concept declaration e.g. no if constexpr (requires { foo; }) was a syntax error ; clang wasn't claiming concepts support but I couldn't find a thing that didn't work at the time.
Same for coroutines, constexpr, my codebase at some point was littered with workarounds just for catering to MSVC's idea of conformance. Even today it's the compiler for which I have the most open bugs I think.
And, to put the nail on the coffin, clang generates consistently faster code in my experience and its of many others, see e.g. this recent thread on r/cpp : https://www.reddit.com/r/cpp/comments/100vctp/msvc_vs_clang_...