Visual Studio & Visual Studio Code

Visual StudioVS Code
IDECode Editor
Suitable for development collaboration
:: Create new project
:: Empty Project for C (Console App for C++)
:: R-click project name @ explorer @ right> Add > New Item (will be under Source Files after adding)
:: Click play (Local Windows Debugger) to run

VS & VS Code

  1. Install the Microsoft Visual C++ (MSVC) compiler toolset
    • Search for and install Build Tools for Visual Studio 20xx @ Older Downloads in Visual Studio Downloads page

Confirm compiler with cl.exe (which is the C/C++ compiler driver) by executing cl in the Developer Command Prompt for VS (located here by default: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 20xx\Visual Studio Tools)

Install Mingw-w64 (follow install instructions @ MSYS2)

Set to System variables PATH (C:\msys64\mingw64\bin)

Create tasks.json: Terminal > Configure Default Build Task > cl.exe

command gets VSC to run cl.exe

args arguments (order crucial) to pass to cl.exe

${file} is the active file

/Fe: switch to create exe

exe is created in present directory ${fileDirname}

${fileBasenameNoExtension}.exe is the created exe file using the cpp’s filename (e.g. abc.cpp builds to abc.exe)

label is seen in the tasks list (name is customizable)

problemMatcher selects the output parser to use for finding errors and warnings in the compiler output. For cl.exe, you’ll get the best results if you use the $msCompile problem matcher.

group is object

“isDefault”: true runs task with Ctrl+Shift+B (if set to false, run task @ Terminal > Run Build Task…)

Build task by running task (explained above) (prerequisite: VS Code to start from Developer Command Prompt for VS with code .)

Run task by typing .\<filename>.exe

--- :: Skyferia Tech's Related Posts :: ---