7++ reasons to move your C++ code to Visual Studio 2017

Whether you are a full-time or occasional C++ developer, whether you are using an older Visual Studio version or are considering using Visual Studio for the first time, this blog post is for you.

In this post I share seven reasons why Visual Studio 2017 should be your first choice of IDE for C++ development (to quickly jump to each section of this blog post, follow the links below):

  1. Take advantage of the latest compiler and Standard Library to write modern, portable C++ code
  2. Leverage the binary compatibility for a pain-free upgrade from Visual Studio 2015
  3. Be on the fastest path to the edit-build-debug inner-loop with the dramatic speedups in startup and project load
  4. Enjoy the productivity enhancements in the developer inner-loop
  5. Easily bring your non-MSBuild C++ projects to Visual Studio
  6. Target any platform including Android, iOS, Linux, and Windows from a single IDE
  7. Streamline your installation of C++ workloads

For those of you that prefer to learn more about this topic in video format, check out the 7++ reasons to move your C++ code to Visual Studio 2017 BUILD breakout session.

#1 Write modern, portable C++ code

There are multiple reasons why we choose C++ when we write code: code portability, runtime performance or low power consumption. At the end of the day, many of us also love writing C++, and it is our desire to better ourselves to write modern C++.

C++ Conformance

Visual Studio 2017 comes with a big update in terms of C++ language conformance. It supplies a close to complete list of new features in the C++11 and C++14 standards. Only three features remain unimplemented: two-phase name lookup from C++98, a conforming preprocessor, and a complete implementation of Expression SFINAE. Visual Studio 2017 also makes great progress towards C++17 with many new compiler and libraries features.

The C++ team will continue its work on C++17 and the C++ compiler rejuvenation effort will bring the missing C++98 features. In addition, Visual Studio 2017 comes with support for several C++ Technical Specifications:

I encourage you to try them all and provide feedback to the Standards body before they become part of the C++ standard.

C++ Core Guidelines, Checkers, and Support Library

If you are looking for guidance on how to write modern C++, a group led by Bjarne Stroustrup created the C++ Core Guidelines with the goal of helping people use modern C++ effectively.

To help with the adoption of the C++ Core Guidelines in your organization, Visual Studio 2017 ships with C++ Code Analysis tools (known as C++ Core Checkers) that validate your code against the guidelines, running bounds checks, type checks (including const checks) and resource management checks and then making suggestions on how to improve your code. The links in each suggestion point to the relevant parts of the guideline document that discuss the specific suggestion.

Code Analysis

The C++ Core Checkers go hand-in-hand with the C++ Guideline Support Library, a header-only library that contains helper functions and types suggested by the guidelines to be used in your modern C++ codebase. This library is available as a GitHub repo, a NuGet package, and through VCPkg.

#2 Pain-free upgrade

Moving your C++ code between Visual Studio versions sometimes can create a bit of friction, especially if you are dealing with a large codebase or you depend on 3rd party libraries that haven’t announced their support for the latest MSVC compiler yet. In fact, the primary migration blocker we hear from developers in our surveys is the fact that a 3rd party dependency, either open-source or proprietary, has not yet been migrated.

VC Runtime binary compatibility with Visual Studio 2015

The single most important feature of Visual Studio 2017 if you are upgrading from Visual Studio 2015 is that the new VC Runtime is binary compatible with the VC Runtime shipping in Visual Studio 2015.

What this means in practice is that you can move your code to compile with the latest MSVC compiler and libraries even when your 3rd party dependencies have not yet moved!

VCPkg – acquire and build hundreds of C++ libraries on Windows

If you are depending on an open-source library, chances are you will find it in VCPkg’s list of supported C++ libraries for Visual Studio 2017. VCPkg (video here) has more than 220 open-source C++ libraries readily available.

Acquiring and building a C++ library on Windows has never been easier:

REM Get VCPkg from GitHub

git clone https://github.com/Microsoft/vcpkg.git

 

REM Bootstrap VCPkg

.\bootstrap-vcpkg.bat

 

REM Install 3 libraries: curl, Boost, and GSL

.\vcpkg install curl boost ms-gsl

 

REM Integrate with Visual Studio

.\vcpkg integrate install

 

Install MSVC 2015.3 toolset with Visual Studio 2017

If you are only looking to use Visual Studio 2017 without upgrading your VC projects, that is now easier too. In previous releases, you had to install both the latest and the old Visual Studio versions, side-by-side, for the latest IDE to be able to build your projects.

You can now install just the MSVC toolset directly from the Visual Studio 2017 Installer by selecting the “VC++ 2015.3 v140 toolset (x86, x64)” option from the “Desktop development with C++” workload.

Migrating from Visual Studio 2013 or older?

If you are upgrading your C++ projects from Visual Studio 2013 or older, even 2003, you will find that we’ve put significant effort in making the Visual C++ migration documentation as complete and accessible as possible, documenting the compiler and linker errors you might encounter, explaining the reasons behind them and how to address them.

#3 Fastest IDE

When it comes to performance, Visual Studio 2017 brings dramatic performance improvements that vastly change the responsiveness of the IDE, making it truly feel faster:

The IDE now also monitors the performance characteristics of all VS extensions, notifying you in case of slowdowns originating from an extension during IDE startup, solution load, and typing.

#4 Productivity in the developer inner-loop

For many of you, productivity is the main reason you are using Visual Studio. The Visual Studio IDE saves you time in your everyday development when it comes to editing, building, testing, diagnosing as well as committing your code to source control.

Visual Studio 2017 includes a lot of new features as well as many user-suggested enhancements to existing functionality that will bring you unparalleled productivity to your C++ development inner-loop.

Editing & code navigation

The Find All References window has been redesigned from the ground-up to scale to larger result sets with incremental results display, better filtering, sorting, and searching within results. You can now also differentiate between reads vs. writes for fields/variables/parameters.

Find All References

The Go To window (“Ctrl+,”, previously called Navigate To) becomes the central hub for code navigation by unifying several operations under one roof: ‘go to line’, ‘go to file’, ‘go to type’, ‘go to member’, and ‘go to symbol’.

Predictive IntelliSense uses contextual information to limit the number of results displayed by Member List or AutoComplete List to only those results that are the most obvious candidates for the current code location. This is an experimental feature that you will need to first turn on from Tools > Options > Text Editor > C/C++ > Experimental >> Enable Predictive IntelliSense = True

Before After
Predictive Intellisense - before Predictive Intellisense - after

Diagnostics

Compile-time /diagnostics:caret provides better warning/error messages by including column information as well as source context.

Exception Helper improves a common scenario of debugging and diagnosing a first-chance or unhandled exception by breaking on the line the exception is thrown, displaying summary info about the exception, and performing an access violation analysis (if applicable).

Exception Helper

Run to Click makes it a lot easier to debug your code without the need to set temporary breakpoints or use the context menu (to invoke Run to Cursor).

Run To Click

Reattach to Process is a one-click shortcut to reattach to the previously attached process without having to navigate through the Attach to Process dialog every time.

CPU Usage Caller/Callee View allows deeper analysis of the cost of functions calls, directly while debugging.

C++ Unit Testing

Writing unit tests is the perfect way to validate individual components of your code and running them on an ongoing basis avoids regressions. But running the tests on the command line breaks your inner-loop productivity. Visual Studio’s goal is to make this experience as seamless as possible, enabling you to run the tests right after you make edits to your project.

Unit Testing

Visual Studio 2017 adds support for Google Test (with Boost.Test coming soon) allowing you to easily create, enumerate and run tests, and optionally measure their code coverage directly from the IDE regardless of the unit test framework you choose to use.

Source control

In addition to the performance improvements for git operations mentioned above, Visual Studio 2017 allows you to do more of your end-to-end workflow without leaving the IDE. You can:

  • perform a force push to complete a release or push an amended commit
  • easily view the diff between two commits
  • unset your upstream branch
  • connect through SSH

In addition, with Visual Studio 2017 and the Continuous Delivery Tools for Visual Studio extension, you can subject every commit to higher scrutiny by reviewing your C++ Code Analysis results before committing.

Continuous Delivery Tools

#5 Bring your C++ sources to Visual Studio with Open Folder

Now, I know that not all of you reading this post are Visual Studio users considering upgrading to the latest version. Some of you may be using other C++ IDEs or editors, considering adopting Visual Studio. But you might think that your codebase (which doesn’t come with .vcxproj and .sln files) is not well suited for loading inside Visual Studio. You might believe that the productivity features that I just outlined for you above couldn’t possibly work with your CMake or makefile project. This next reason addresses exactly your concern.

Visual Studio 2017 supports opening folders containing any code without the need to create solutions or projects (video here). Via “Open Folder”, you will have a more natural way to manage your files regardless of the build system you choose to use or the environment/platform you choose to target. With very little configuration, you get access to all the powerful C++ code understanding, editing, building, and debugging capabilities that you come to expect from Visual Studio with MSBuild projects.

While the out-of-the-box experience today allows you to only target the Windows environment, Visual Studio 2017 will soon add support for MinGW and Cygwin environments as well. To see a sneak peek at the experience, check out this MinGW demo during the C++ Panel at BUILD 2017 (click to jump to 2:20m).

Debug MinGW Cygwin

CMake support

If you have a CMake project, you will enjoy the built-in support for CMake in Visual Studio 2017. You can open any folder containing CMakeLists.txt and Visual Studio will automatically start configuring your CMake projects, discover all your CMake targets, and provide you with:

  • accurate C++ IntelliSense when editing based on exactly how your files are being built
  • C++ code navigation and refactoring (rename refactor, extract function, move definition location, change signature, etc.)
  • CMake build integration through either Ninja or Visual Studio generators
  • debugging of any CMake executable targets
  • running CTest tests authored in your CMake projects
  • leverage the latest CMake release 3.8

CMake

The experience of developing your CMake projects with Visual Studio should not be limited to only targeting Windows. With that in mind, Visual Studio 2017 will soon expand support to allow targeting Linux with CMake as well. To see a sneak peek at that experience, check out the CMake Linux demo at BUILD 2017 (click to jump to 42:00m).

CMake Linux Prototype

#6 Target Windows, Android, iOS, and Linux from a single IDE

In addition to C++ development for Windows Desktop and Universal Windows Platform, Visual Studio also comes with support for targeting Linux, Android and iOS. Visual Studio 2017 is the one IDE that allows you to target any platform from a single IDE without having to switch your development box.

Linux targeting

Visual Studio 2017 has built-in support for Linux development, allowing you to very easily connect to remote Linux machines, local or Azure VMs running Linux, and even Windows Subsystem for Linux in Windows 10. The requirements for the remote Linux system are very low: you need an SSH server with gdbserver and a C++ compiler installed. You can also share your C++ code easily with projects targeting other platforms.

Linux Targeting

Android targeting

Visual Studio 2017 not only supports editing, building, and debugging of C++ code targeting the Android platform, but also editing, building, and debugging Java code. For more details, read our Android and iOS development with C++ guide.

Android Targeting

iOS targeting

With Visual Studio, you can import your C++ Xcode projects, benefit from all the C++ productivity improvements Visual Studio 2017 provides, and if needed you can always reopen your projects in Xcode for specific operations like storyboarding or iOS localization that are not directly supported by Visual Studio today.

#7 Streamlined installation

All of this new functionality in Visual Studio 2017 can be acquired via a fresh new installer that organizes the Visual Studio installation options into specific workloads that you can easily choose from. The workloads that are most relevant to C++ developers are:

  • Desktop development with C++
  • Universal Windows Platform development
  • Mobile development with C++
  • Game development with C++
  • Linux development with C++

This new approach has three major benefits:

  • By only installing what you need, Visual Studio’s footprint on disk will be much smaller.
  • With fewer bits to install, the installation time is greatly reduced (e.g. you can install the C++ Desktop workload in under 12 minutes on a good dev box with a good Internet connection).
  • Additionally, you end up with less visual noise inside the IDE from components you usually don’t use.

#7++ You helped build it

And finally, the reason you should use Visual Studio 2017 for your C++ development is that you helped build it!

This release incorporates so many of your suggestions and bug reports that it is hard to imagine how the product would’ve worked without them. Thank you! Visual Studio 2017 addressed UserVoice items that amount to 1,540+ votes and fixed 980+ bugs reported via Connect and through the IDE.

Please report your feedback via UserVoice (for suggestions) and directly in the IDE via Help > Send Feedback > Report A Problem (issues reported are visible at https://developercommunity.visualstudio.com). The Visual Studio team spends a lot of time reading this feedback and incorporating it, one way or the other, into the upcoming releases, so keep it coming.

Get started today

Visual Studio 2017 is the one IDE that gives you the best C++ development experience regardless of the build systems you use (MSBuild, CMake, Ninja, make, etc.), regardless of the C++ libraries you depend on (see vcpkg library manager above), and regardless of the platforms you target (Windows desktop, Linux, etc.)

Download Visual Studio 2017 today and please share your feedback. We hope you’ll enjoy it. Happy coding!

Marian Luparu, Principal Program Manager, Visual C++ Team
@mluparu
@visualcMarian is a Product Manager in the Visual Studio team, focusing on C++. He joined the Visual Studio team 11 years ago, after being an avid user of Visual C++ and Visual Studio.