VS Code Gets Better At Make C/C++
Wednesday, 06 December 2023

VS Code is a "go-anywhere, work-with-anything" dev system. However, not all languages are created equal and build systems for C/C++ are particularly challenging. The latest VS Code does something to make it easier.


Have you ever started to use a function and forgotten to put in an include for the header file? Worse, forgotten which header file it is in anyway! It slows you down having to look up the name, but  you might be able to put this problem behind you. VS Code now has a quick fix suggestion that lists possible header files and will auto-add the include if you select one. It beats seeing the error message "did you mean x" and then having to manually add x.

At a higher level we now have a facility to extract to function. Highlight the code, use Extract to function and a call to the function is inserted and code removed to form a new function. If only it could supply the function's name I could go home early.


Another nice touch is the ability to install a compiler - not something you do often but when you do it is generally at the start of a project and you can't wait to get coding. The big letdown is that it only works with Linux and Mac and both generally come with a compiler installed anyway. If only it would do the job for Windows and install, say, GCC to replace the non-C standard Microsoft compiler then this would be worthwhile. Instead what we have is an Intellisense option that lets you install MSVC - but only after attesting that you have a valid Visual Studio Licence! Now this is getting silly. If you read the start of the licence it says:

"You may install and use any number of copies of the software to use solely with Visual Studio Community, Visual Studio Professional, and Visual Studio Enterprise (collectively, “Visual Studio Products”), to develop and test your applications; and.."

So not VS Code then...

Microsoft really does have to sort out the relationship between the "paid for" Visual Studio and the "free" Visual Studio Code. At the moment you don't have to pay to use the extensions that they provide, but you have to register.

Along with the C/C++ extension, the CMake extension has been improved. Its biggest problem is the way that it tends to hide itself. So much so that when I talk to beginner users I very often find that they haven't actually discovered its status bar and side bar menu. It now has a nice new icon that actually looks like something to do with CMake. In addition they are decluttered and customizable. Putting this together with the CMake Debugger introduced recently and VS Code is starting to be a very attractive C/C++ development tool for a range of different targets.

It is also a capable mixed-language system as I discovered recently while working on my recent book on Python Extensions. I found I could debug the C part and the Python part almost without noticing the join - well perhaps this is an exaggeration,  but it was easier than anything else I've tested.

What VS Code lacks at the moment is documentation that covers the less well trodden paths - and it urgently needs a good way to let you run C code as root, a problem that is particularly acute when working in an IOT context. 


  • As well as being editor-in-chief of I Programmer, Mike James is also a prolific author. VS Code is now his preferred code editor and is used throughout his Programmer's Python: Something Completely Different series of books and in his most recent title Extending & Embedding Python Using C, a book which takes a "best of both world's approach" - C for speed and Python for ease of programming.

More Information

Visual Studio Code CMake Tools Extension 1.16 Update: New CMake Tools Sidebar and CMake Debugging options

C++ Extension in VS Code 1.18 Release: Quick Fixes for missing header files, Extract to Function & More

Related Articles

CMake Debugger Added To VS Code

VS Code Can Do More Than You Imagine

VS Code Adds Terminal Tabs

Python Extension For Visual Code Updated

Visual Studio Online Is VS Code

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.



Meet Ambidex and Rookie From NAVER

Robots may not be ready yet for the great takeover of jobs that some people fear, but in South Korea, where there are 1,000 robots per 10,000 workers, service robots are finding a role. 

Apache Arrow 16 Adds Azure Blob Support

Apache Arrow 16 has been released with improvements to the C data interface and to Arrow Flight RPC, and the addition of support for Azure Blob data format.

More News

C book



or email your comment to: comments@i-programmer.info





Last Updated ( Wednesday, 06 December 2023 )