August Update for the Visual Studio Code C/C++ extension
At //Build this year we launched the C/C++ extension for Visual Studio Code. Keeping with the monthly release cadence and goal to continuously respond to your feedback, this August update introduces the following features:
• Debug your Windows applications using Visual Studio Code • Improve your code-formatting experience with clang-format • Improvements to auto-complete
If you haven’t already provided us feedback, please take this quick survey to help shape this extension for your needs. The original blog post has already been updated with these new feature additions. Let’s learn more about each one of them now!
Debug your Windows applications using Visual Studio Code
With this August release we are excited to announce that we are adding support for debugging Windows desktop applications to the Visual Studio Code C/C++ extension!
To debug your Windows application you can follow these steps:
• Navigate to the Debug view on the Sidebar in Visual Studio Code • Click the Configure (gear) icon • Select ‘C++ (Windows)’
• You will need to set the value of the ‘program’ field to point to the binary you are debugging for both configurations (launch, attach) • To configure additional locations for the debugger to search for symbol (pdb) files, add a ‘symbolsearchpath’ property to the launch.json configurations (separate multiple paths with a semi-colon)
This preview of Windows debugging support adds the following capabilities:
• Debug x86/x64 applications • Launch and Attach support desktop applications • Breakpoints (File, Line, conditional and function) • Stepping • Watch and DataTips • Call Stack • Symbol configuration (‘symbolsearchpath’) • Multi-threaded debugging
• Source must be in the same location that it was compiled from • No support for asynchronous call stacks
Improvements to your code-formatting experience with clang-format
As a part of the June update for this extension we added support to format your C/C++ code with clang-format. The improvements that this update brings are that clang-format is now installed as a part of this extension. In addition to this the formatting experience now formats your code on the go as you type and we also allow for formatting for only a section of code vs. the entire document when using the ‘Right Click-> Format Code’ option.
To set and control formatting for clang-format we have introduced a variety of options, which you can override in your workspace, user settings file to tailor the formatting experience for your needs. One change you will see with this release is that we now default to a ‘fallback-style’ of ‘Visual Studio’ vs. ‘LLVM’. This change is primarily made to make sure your formatting settings between Visual Studio and Visual Studio Code are as similar as possible. Currently the Visual Studio style maps to these options for clang-format. The new “Visual Studio” style is not yet officially part of clang-format, but implies the following format options.
Other options include the ability for a user to provide and use a custom version of clang-format, enable auto-formatting when saving the source file and also control popular clang-format tool options (style, fallback-style, sort-includes) as a part of the workspace, user settings. These last set of options to control the clang-format behavior was earlier present as a part of the ‘c_cpp_properties.json’ file, which we have now cleaned up and all clang-format options are consolidated as a part of the Visual Studio Code default settings.
Improvements to auto-complete
Another experimental feature we launched as a part of the June update was the alpha version for the auto-complete feature. The feature provides auto-complete using the symbol database populated to power the code-navigation features such as peek and go-to definition. This feature is an addition to the single-file intellisense experience Visual Studio Code provides by default based upon the text-mate bundle.
Since the release of this feature we have heard strong feedback w.r.t. how today both these intellisense experiences (single file, fuzzy auto-complete) interfere with each other and as a result resulting in a high degree annoyance for our users. With this release we have fixed this experience and now a developer can choose between the two intellisense modes by using the ‘C_CPP.Autocomplete’ option in the workspace, user settings. The default experience today currently is to provide fuzzy auto-complete only.
Note that this is a preview feature and while this update does not address all of the issues you will likely run into, further improvements are on the horizon!
Update your extension now!
If you are already using the C/C++ extension, you can update your extension easily by using the extensions tab. This will display any available updates for your currently installed extensions. To install the update, simply click the Update button in the extension window.
Please refer to the original blog post for links to documentation and for more information about the overall experience of Visual Studio Code C/C++. Please help us by continuing to file issues at our Github page and keep trying out this experience and if you would like to shape the future of this extension please join our Cross-Platform C++ Insiders group, where you can speak with us directly and help make this product the best for your needs.