Visual Studio CODE is on the market for quite a while and thanks to its simplicity, lightweight and compatibility with variety of programming languages, it becomes a must-have for any programmers. For myself, I started using it 3 years ago, when I had to edit VHDL codes, which seemed like a nightmare in Xilinx’s build-in editor for VHDL files. Not also to mention the Xilinx’s Eclipse-Based IDE (XSDK) and Eclipse overall even for C++ development. Thanks to all kind of extensions, you can easily integrate VS CODE with variety of other tools and compilers, which among the most favorite ones are definitely GIT and C/C++ (Or at least I Believe so).

The only thing, that remained an unexplored ground for me was the possibility of using VS CODE for project build and debugging, because so far, I have used it only as an advanced text editor for all kind of files. In fact, configuring the VS CODE to compile a C++-based project is quite simple in case you have full Visual Studio Installed as well as the C/C++ package for CODE. Using MS CODE to actually build a project based on the MS compiler might seem odd, but its more likely an introduction, as the project could be configured to be build by MiniGW or with many other compilers. 

First, we have to launch the Development tools for Visual Studio CMD. From within the terminal, navigate to your project location and open VS CODE in project mode “code .” (Include the dot, as this tells VS CODE that we are opening a project location). We start by creating a “Helloword” – simple Source.cpp with nothing more than a simple std::cout << “Oh Hi There!”<<std::endl;

 

Once this is done, we need to make sure of 2 things: The C/C++ is configured correctly. We can check so by going to command palette and typing “C/C++ Configuration”. Make sure that when the settings.json opens, there will be:

“intelliSenseMode”: “msvc-x64”,

You can checkout the reference Microsoft’s guide HERE or just copy/paste from the following snippets. Please note that some changes may be necessary according to your current Windows SDK Version or whatever. The next step is to configure a default build-task for the project. This is also done through the command palette. See image gallery for more details, but basically its just another CTRL-C/CTRL-V.

CPP Settings

 

Build Task

 

 

Now we are ready to go, hit F5 or navigate to Debugging menu and enjoy VS CODE with C/C++ support. Make sure to also visit MS Guide for setting up different compilers in case they are needed. Happy coding!

Share This