MSVC: The best choice for Windows
The C++ product team here at Microsoft offers a great C++ experience in the Visual Studio IDE, the Visual Studio Code editor, and various other tools and services. That includes the topic of this blog post: the Microsoft Visual C++ compiler and libraries toolset (MSVC).
Our goal for MSVC is to be the best compiler choice on Windows for targeting Windows, regardless of what editor or IDE you choose to use. We aim to deliver on our goal with continuous investments in the following key areas: full C++ conformance, better errors and warnings, runtime performance, reliability, build throughput, and the best security. Let’s look at each one in more detail.
The best C++ conformance
Getting to full conformance with the C++ Standard is our number one priority when it comes to our compiler. We’ve written a dedicated post discussing our road to conformance. Please go read C++ Standards Conformance from Microsoft.
Better errors and warnings
Effective compiler diagnostics are hard. We know that there are many places where our warnings and errors could improve. We’ve started small, by indicating the column number in MSVC diagnostics. But there is more targeted work to come in the area of improved diagnostics: conforming behavior for ternary operator, missing diagnostics for incorrect code, detailed continuation messages for generic error codes, better warning level configurations for system headers, and more. Look for details on this blog in the coming months.
Similarly, we’ve been making great strides in the quality and variety of warnings generated from our C++ code analysis. One good example of this is the C++ Core Guidelines checkers, which ship as part of VS 2017. These checkers are built to enforce rules in the C++ Core Guidelines, a cross-industry coding standard that helps you write code that is correct by design.
Code generation and optimization (runtime performance of your code)
We have three goals in optimizing your code, and we aim to be the best in each area:
- Runtime performance of your code: we want it to run as fast as possible.
- Reliability and correctness: It doesn’t matter how fast your code is if does the wrong thing. Our first focus is reliability of the compiler and correct code generation.
- Security: Lots of tools search for memory vulnerabilities from “outside the box”. Our optimizer contains powerful technology to make your code safe without tools.
With regards to runtime performance, our optimization framework got a big rewrite with VS 2015 Update 3. MSVC’s new SSA (static single assignment) optimization framework opens up new possibilities for how we can make your code run faster. We’re taking advantage of this new optimization framework in VS 2017 to make your code faster.
Optimization isn’t just about speed: it’s about correctness. We test our compiler, libraries, and optimizer daily by building Windows and Office as well as more than 50 OSS projects. We also have almost a million custom-written regression tests that run with every source change checkin, full-suite testing with several hundred thousand more tests daily, and performance and throughput testing.
There are many tools that try to make your code secure from outside the box: Valgrind and address/thread sanitizers are popular examples. And there are many of these tools on Windows as well, both from Microsoft and other companies. But MSVC features powerful technologies inside the compiler that integrate security with your code. For example, Control Flow Guard, is highly-optimized security feature that combats many memory corruption vulnerabilities. We can’t talk openly our current security research but we’re always working to make your code (and ours!) safe from increasingly sophisticated attackers.
We’ve also greatly improved build throughput: making our compiler toolset compile your code faster. Features like
/debug:fastlink in VS 2015 reduced link times by 2-4x. In VS 2017, feature improvements to
/debug:fastlink give an additional 30% reduction in link time. Here are more suggestions on how to use
/debug:fastlink as well as other techniques for faster build times.
How do I get the newest MSVC toolset?
The best way to get our compiler and libraries toolset is as part of the latest version of Visual Studio. Major changes to the VS installer let you install just the parts you need. You can install just the C++ workloads without having to install other languages if that’s what you prefer. You can also optionally install workloads for specific C++ scenarios.
You can even install the C++ Build Tools on your build machines without needing to install the VS IDE. These are the same tools that are installed with VS 2017 but are intended for build machines. There’s usually no need to install an IDE on a build machine because no development happens on the machines. With VS 2017 you can choose to install just the MSVC toolsetin a scriptable, standalone installer.
What if you want to check out new features that have been implemented since the last VS update? We’ve created a simple way to try out a new toolset with an easy-to-install NuGet package that installs in a C++ project or solution. We’ve also helped to get our compiler toolset integrated on the Compiler Explorer at gcc.godbolt.org, a popular web app that lets you compare compiler features and code generation across many C++ compiler toolsets.
For libraries, we’ve created a Windows-specific library package manager that lets you quickly and easily install many open source libraries directly from their repos. We started with an initial list of libraries that you suggested in a survey, plus some of the most popular libraries from GitHub. The number of supported libraries that you can install with VCPkg is always growing.
If you encounter other problems with MSVC in VS 2017 please let us know via the Report a Problem option, either from the installer or the Visual Studio IDE itself. For suggestions, let us know through UserVoice. Thank you!