Visual Studio Code C/C++ extension: March 2019 Update

Tara

April 4th, 2019

The March 2019 update of the Visual Studio Code C/C++ extension is now available. This release includes many new features and bug fixes, including IntelliSense caching, Build and Debug Active File, and configuration squiggles. For a full list of this release’s improvements, check out our release notes on GitHub.

IntelliSense Cache (AutoPCH)

The extension will now cache header information to improve IntelliSense speed. This is similar to precompiled header files in Visual Studio. Please note that IntelliSense caching works on Linux, macOS 10.13+ (High Sierra and later versions), and Windows.

Precompiled Headers (PCH)

Precompiled headers (PCH) can be used with compilers to speed up build times by taking the #include header files in your code and compiling them for reuse later. Without precompiling headers, IntelliSense needs to process the header files and source code. But, if your header files do not change, it is not actually necessary to process the header files again.

With AuotPCH, the IntelliSense compiler will generate a separate PCH for the use of the IntelliSense compiler. Caching of PCH files reduces the parsing time of #include header files to improve IntelliSense performance.

IntelliSense Cache Settings

By default, the cached PCH files are currently stored in your workspace folder’s “.vscode” folder under the subdirectory ‘ipch’. You change this location via the “C_Cpp.intelliSenseCachePath” setting. You can also control how much disk space can be used for the cache with the “C_Cpp.intelliSenseCacheSize” setting. The cached PCH files can be large, depending on the size and number of #include header files. The default cache size (for all files under the C_Cpp.intelliSenseCachePath) is 5120 MB. IntelliSense caching can be disabled by setting the cache size to 0.

Build and Debug Active File

To simplify the build and debug experience with the C/C++ extension, we added a command to help you generate build and debug tasks for single code files. We write out to your tasks.json and launch.json when you press F5 or select the command from the context menu , which automatically configures the tasks and kicks off a build and debug session . So, you no longer need to go through many of the configuration steps previously required to build and debug your active Here’s an example with a simple project :

Please Note: Since this feature writes out tasks.json and launch.json files, it currently requires that a workspace folder be opened first. Using this command will remove comments from the tasks.json and launch.json files. If you are on Windows and wish to use the cl.exe compiler through Visual Studio, you need to open the workspace folder and launch Visual Studio Code from the Developer Command Prompt using the “code .” command.

Configuration Squiggles

On our path to improving the configuration experience, we added additional validation to the c_cpp_properties.json file to assist in diagnosing potential configuration mistakes. These validation checks can be seen with error squiggles . The error squiggles are shown for invalid paths for properties like includePath and compilerPath. We also show error squiggles when a folder is used instead of a file or vice versa. The detected issues will also show up as “Problems” in the problems window:

We will continue improving the configuration experience in future releases.

Tell Us What You Think

Download the C/C++ extension for Visual Studio Code, give it a try, and let us know what you think. If you run into any issues, or have any suggestions, please report them on the section of our GitHub repository. Set the C_CppProperties.UpdateChannel in your Visual Studio Code settings to “Insiders” to get early builds of our extension. to get early builds of our extension.

Please also take our quick survey to help us shape this extension to meet your needs. We can be reached via the comments below or via email (visualcpp@microsoft.com). You can also find our team on Twitter (@VisualC).