Today we’re very happy to announce the availability of the June 2018 update to the C/C++ extension for Visual Studio Code! In this update, we are continuing our efforts to make IntelliSense configuration easier by auto-detecting compile_commands.json files for IntelliSense, significantly improving recursive search performance, making browse.path optional, and adding “compilerPath” support for MSVC.
IntelliSense auto-detects compile_commands.json
In this update, compile_commands.json files in the workspace will be detected to auto-configure IntelliSense, eliminating the need to manually specify includes and defines.
Compile_commands.json file is a compilation database that consists of an array of “command objects”, where each command object specifies one way a translation unit is compiled in the project. Its format is specified in the Clang documentation, and it can be generated by many build systems, such as CMake. The C/C++ extension added support for it in the October 2017 update, but it was an optional setting that required manually setting the path to the file. This latest update added auto-detection to make use of such files. If multiple files are found, you will be presented with a dropdown to choose the appropriate one. The following screenshot shows an example of the message suggesting the use of a compile_commands.json file to auto-configure IntelliSense and the dropdown with two choices.
Once selected, IntelliSense will be fully powered by using the information in that file with no further configuration required. If you need to change the path, you can find the “compileCommands” setting in the c_cpp_properties.json file (access via Command Palette -> C/Cpp: Edit Configurations…).
Performance improvement for IntelliSense path recursive search
Support for recursive search of “includePath” was added in the May 2018 update. This latest update significantly improves the search performance on large folders. By intelligently cutting down the number of paths that need to be processed by the IntelliSense engine, we were able to make search faster – in particular, subsequent folder opening is orders of magnitude faster. Due to these improvements, recursive search is now the default behavior for newly-opened folders. To opt out, simply remove “**” from each path in the c_cpp_properties.json file.
Browse.path is now optional
For the longest time, we had two path settings: “includePath” for the IntelliSense engine, and “browse.path” for the Tag Parser. The IntelliSense engines document explains the difference between the two. While it could be useful at times to have different sets of paths, in many cases they end up being duplicated. In this update, we’re making “browse.path” optional, which means it won’t be populated in newly-created c_cpp_properties.json files. The “includePath” values will be used for the Tag Parser in addition to the IntelliSense engine, if “browse.path” is not present.
compilerPath setting added support for MSVC (Microsoft Visual C++ Compiler)
“compilerPath” is a setting introduced previously that allows users to specify a compiler from which IntelliSense can retrieve system includes and defines. This update added support for MSVC – this means the “compilerPath” setting in the default Windows configuration will use the latest MSVC installed on the machine for includes and its value can be changed to a different version if needed.
Tell us what you think
Download the C/C++ extension for Visual Studio Code, try it out and let us know what you think. File issues and suggestions on GitHub. If you haven’t already provided us feedback, please take this quick survey to help shape this extension for your needs.