Visual Studio Code C/C++ extension June 2017 Update

Today we are excited to announce the release of the June 2017 update of the C/C++ extension for Visual Studio Code. This update enables semantic-aware member list auto-completion and improves the overall default IntelliSense behavior, providing a smoother out-of-box IntelliSense experience.

If you haven’t tried it before, download VS Code (Stable build) or VS Code Insiders. Then download the C/C++ extension for Visual Studio Code to try it out. If you have this extension installed already, VS Code will notify you of the update and install it automatically.

The original blog post, which provides an overview of this extension, has been updated with these changes.

Improved IntelliSense experience

In last month’s update, we enhanced the operation of our original tag parser IntelliSense engine that typically provides “fuzzy” results for editing features with a new, more powerful semantic engine. This new engine provides the capability to provide more productive language service features. As with the May update, the new engine is on by default only for VS Code Insiders. However, everyone else is encouraged to try it out themselves by changing the “C_Cpp.intelliSenseEngine” setting in your settings.json file from “Tag Parser” to “Default”.

After updating your includePath to find all headers, the new IntelliSense engine will be able to provide more accurate autocomplete suggestions for class/struct/namespace members, quick info tooltips, and error squiggles (linting). The new IntelliSense engine is used whenever possible as the default. In the cases when the engine returns errors, the extension dynamically falls back to use the tag parser for opened file. See section “How fallback works and how to control the behavior” below for more details.

Member List Autocomplete

Unlike the tag parser, the new semantic engine can determine type and therefore provide a more concise and accurate list of completion items when you type “.”, “->” or “::”.

Please note that this functionality is not enabled at the global scope when typing “::” or when providing quick suggestions when no scoping character is provided. The tag parser continues to provide suggestions for both cases.

IntelliSenseMode setting

In the May update, the semantic engine limited compiling code in “MSVC mode” on Windows and “Clang/GCC mode” on Linux and Mac. In this update, we added a setting that lets you choose which mode to compile your code in regardless of the platform on which you’re running.

For example, if you are using MinGW on Windows, you can now instruct the IntelliSense engine to use “Clang/GCC mode” instead of “MSVC mode”. The mode can be configured by modifying the “intelliSenseMode” property in the active config in your c_cpp_properties.json file.

How fallback works and how to control the behavior

The extension first tries to fully parse any opened file using the new IntelliSense engine. If it discovers that it cannot find a header file or a dependency, it will fall back to the tag parser and provide the original fuzzy IntelliSense behavior. The fallback affects a full translation unit (TU), not just a single open file. Other opened TUs will continue to use the new IntelliSense engine provided that all #include dependencies are resolved. This behavior effectively addresses the “sea of red squiggles” many users saw in the May update by only showing green squiggles for any #include statements that could not be resolved. The Problems panel provides details about unresolved headers and dependencies.

To support the new fallback experience discussed above and make it easier for users to discover and resolve includePath problems, the extension provides Code Actions next to #include statements that provide a shortcut to add new paths or disable the fallback mechanism. Putting the text cursor on such a squiggle and clicking the light bulb that appears will display these shortcuts.

We recognize that resolving all #include’s may not be necessary for all projects and you may still want to experience the productivity benefits of using the new sematic engine without customizing the default include path. For that, the “Force semantic IntelliSense” action can be chosen. When invoked, all unresolved #include squiggles will turn red and semantic member list and linting will be enabled in all files regardless of whether or not #include statements can be resolved.

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.