Monday, October 20, 2025

Using VSCode for C++ projects

For a long time I thought I only could use Visual Studio to write C++ programs on Windows, because MSVC toolchain requires some particular initializations before being able to run.

Turns out there is a way to smoothly run all the MSVC machinery from within VSCode. The answer is the same I found last year in automating MSVC builds: we need a .bat file to call MSVC’s own .bat, then we invoke VSCode executable right after.

call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
"C:\apps-portable\VS Code\Code.exe"

Save this .bat somewhere, and put a shortcut to it in your start menu, naming it “VSCode MSVC” or something like that.

To my surprise, some things work better in VSCode than in Visual Studio itself:

  • file navigation;
  • file creation and deletion;
  • error reporting – VSCode reports all files with errors, while in Visual Studio I have to build the project and look at the output to see which files are broken.

No comments: