C++ Team Blog
The latest in C++, Visual Studio, VS Code, and vcpkg from the MSFT C++ team
Latest posts

std::string_view: The Duct Tape of String Types

Visual Studio 2017 contains support for std::string_view, a type added in C++17 to serve some of the roles previously served by const char * and const std::string& parameters. string_view is neither a "better const std::string&", nor "better const char *"; it is neither a superset or subset of either. std::string_view is intended to be a kind of universal "glue" -- a type describing the minimum common interface necessary to read string data. It doesn't require that the data be null-terminated, and doesn't place any restrictions on the data's lifetime. This gives you type erasure for "free", as a function ...

C++ development with Docker containers in Visual Studio Code
Containers allow developers to package up an application with all the parts it needs, such as libraries and other dependencies, and ship it all out as one image. This is especially useful for C++ cross-platform development – with containers you can choose to target a platform that runs on a completely different operating system than your developer machine. And even if they are running on the same OS, the container technology ensures that the application will run on any other machines regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the c...

Using MSVC in a Docker Container for Your C++ Projects
Containers encapsulate the runtime environment of an application: the file system, environment settings, and virtualized OS are bundled into a package. Docker containers have changed the way we think about build and test environments since they were introduced five years ago. Visual Studio’s setup and install expert, Heath Stewart, blogs regularly about how to install the Visual Studio Build Tools in a Windows Docker Container. Recently he explained why you won’t find a container image for build tools. Basically, any install that has a workload installed that you aren’t using is going to be bigger than you want....

Visual Studio Code C/C++ extension July 2018 Update and IntelliSense auto-configuration for CMake
Last week we shipped the July 2018 update to the C/C++ extension for Visual Studio Code. In this update we added support for a new experimental API that allows build system extensions to pass IntelliSense configuration information to our extension for powering up full IntelliSense experience. You can find the full list of changes in the July 2018 update in the changelog. As CMake has been the most requested build system for us to provide support for, we’ve been working with vector-of-bool, author of the CMake Tools extension, on an implementation using this new API to provide IntelliSense auto-configuration for ...

Data Breakpoints – Visual Studio 2017 15.8 Update
New to Visual Studio 2017 version 15.8, you can now set data breakpoints from within the Locals, Autos, Watch, and Quickwatch windows! To view official documentation on data breakpoints, check out this post. Data breakpoints allow you to stop execution when a particular variable stored at a specific memory address changes. Prior to version 15.8, data breakpoints could only be set via the Breakpoints window. In this window, a data breakpoint can be set by selecting New > Data Breakpoint.. and then entering the address of the desired variable and the number of bytes you want the window to watch. Setting data ...

MSVC Preprocessor Progress towards Conformance
Why re-write the preprocessor? Recently, we published a blog post on C++ conformance completion. As mentioned in the blog post, the preprocessor in MSVC is currently getting an overhaul. We are doing this to improve its language conformance, address some of the longstanding bugs that were difficult to fix due to its design and improve its usability and diagnostics. In addition to that, there are places in the standard where the preprocessor behavior is undefined or unspecified and our traditional behavior diverged from other major compilers. In some of those cases, we want to move closer to the ecosystem to make...

Shared PCH usage sample in Visual Studio

This post was written by Olga Arkhipova and Xiang Fan Oftentimes, multiple projects in a Visual Studio solution use the same (or very similar) precompiled headers. As pch files are often big and building them takes a significant amount of time, this leads to the popular question: is it possible for several projects to use the same pch file which would be built just once? The answer is yes, but it requires a couple of tricks to satisfy cl’s check that command line used for building the pch is the same as the command line used for building a source file using this pch. Here is a sample solution, which has ...

Support for Unity (Jumbo) Files in Visual Studio 2017 15.8 (Experimental)

This post was written by Olga Arkhipova. Many big codebases use so-called unity (jumbo) builds where many source files are included in one or a few ‘unity’ files for compilation, which makes compiling and linking much faster. Just to avoid any confusion – this blog is NOT related to the Unity game engine. Looking at some customer feedback regarding slow IntelliSense, we found that projects often include both source files and unity files including those source files. Currently there is no easy way to exclude source files from the build and unity files from the IntelliSense parsing, so we do quite a lot of unnec...

Announcing C++ Just My Code Stepping in Visual Studio

In Visual Studio 2017 release 15.8 Preview 3 we’re announcing support for Just My Code stepping for C++. In addition to previously supported callstack filtering, the Visual Studio debugger now also supports stepping over non-user-code. As you “Step In”, for example in an algorithm from the Standard library with a custom predicate or in a Win32 API that has a user callback, the debugger will conveniently step into the predicate or callback you provided rather than the library code that will eventually call your code. After the very warm reception of our debugging improvements in stepping in std::function calls an...