June 1st, 2016

May/June update for the C/C++ extension in Visual Studio Code

Ankit Asthana
Principal Program Manager

We would like to thank all of you who have tried out the C/C++ extension in Visual Studio Code and have already provided rich feedback on your experiences and filed issues and requests with us. We are working hard on incorporating your feedback into the product. Continuing with our effort to make Visual Studio Code as the editor tool of choice for C++ developers with this update of the C/C++ extension, we are introducing the following features:

• Code formatting with clang-format • Fuzzy Auto-Complete for C/C++ code • Debugging on Windows for Cygwin/MinGW applications • Console application debugging with GDB on the Mac • Toggle between Header/Source File (F4)

Now let’s dive into each one of these in more detail.

Code formatting with clang-format

You can now format your C/C++ code with clang-format from inside Visual Studio Code. Currently clang-format needs to be installed manually and the path for clang-format needs to be added to user settings in Visual Studio Code as shown in the figure below.

formating

usersettings By default, the clang-format style is set to ‘file’ which means it looks for a pre-existing. clang-format file, if the. clang-format file is found it applies formatting settings specified in the file. If the. clang-format file is not found the default fallback-style specified in the c_cpp_properties.json file is used. The default fall back style is set to ‘LLVM’ today.

This clang-format behavior is controlled via the settings file ‘c_cpp_properties.json’ file which can be loaded and edited by executing the following command from the command palette.

editconfig

Fuzzy Auto-Complete for C/C++ code

This update of the C/C++ extension in Visual Studio Code also introduces a preview version of a fuzzy Auto-Complete for C/C++ code. It’s based on an enhanced tag-parser approach, in other words no semantic analysis, so while it is not quite accurate it will still provide you more than what single-file intellisense provides you today. Additionally, this fuzzy intellisense approach will work pretty well for straight up C code so try it out and let us know what you think!

intellij

Debugging on Windows for Cygwin/MinGW applications

Another feature  we are adding as a part of this update is the ability for developers to be able to debug their C/C++ Cygwin/MinGW applications using Visual Studio Code. Users can choose to attach to or launch the application to debug directly. In order to use cygwin or MinGW, the debugger path must be set manually in the launch configuration (launch.json). This is done via the ‘miDebuggerPath’ property, as the following figure shows:

vscode-debug

Console application debugging with GDB on the Mac

In our previous release, we did not have the capability to debug console applications on the Mac using GDB. This has been added to this release. There are some known issues still, due to limitations with GDB. Please see the readme for more information.

Toggle between Header/Source file

SwitchHeaderEasily switch between header (F4) and source using the new C/Cpp task added as a part of the extension.

Update your extension now!

If you are already using the C/C++ extension, you can update your extension easily by using the ext update dropdown. This will display any available updates for your currently installed extensions. To install the update, simply click the Update Extension button in the lower right for the outdated extension. You’ll be prompted to restart VS Code.

updates

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. 

Category
C++

Author

Ankit Asthana
Principal Program Manager

0 comments

Discussion are closed.