Windows Compilers - itzjac/cpplearning GitHub Wiki

This section is completely optional and exclusive to Windows.

Use the folder C:\Users\myuser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup and place whatever bat you need to use when starting a user session in your Windows OS. Helpful to grant global access to any application and or tool from the command line.

devenv myprogram.exe

When compiling with cl, it is not actually the OS that calls the WinMain but the C-runtime library. This is usually shipped with every C++ compiler.

  • /Zi or -Zi cl compiler handles both (the later is UNIX style)

  • /Wall enable all warnings

WINDOWS COMMAND CONSOLE

Few windows command line tools to help us find important system paths, and to use in batches on the fly.

Prints all the environment variable values for the environment variables in the current command line context

c:\Windows\system32>set

Prints all the content in the windir variable

c:\Windows\system32>dir %windir%

Creates a new variable local to this shell

c:\Windows\system32>set mynewvar=C:\projects\myprojectA

Print the value of my variable

c:\Windows\system32>echo %mynewvar%

Caveats

  1. Can't access %VS120COMNTOOLS%

SOLUTION Access to Regedit is disable, verify in gpedit.msc UserConfiguration\AdministrativeTemplates\System\[PreventAccessToRegistryEditingTools. The behavior of this setting can be affected by malware or virus.

  1. No %VSXXXCOMNTOOLS% variable found Visual Studio 2019 and above does NOT expose a environment variable globally. From this version and on, the big M changed how the VC command line launches. Oh no, is horrible! Trust me those tools will be changed and removed with the years to come.

Simplest solution at this point, use the following path or if you prefer try the instructions in the the "Oh no" link.


BATCH
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"

⚠️ **GitHub.com Fallback** ⚠️