0

I use CodeRunner for VSCode on Windows, so I need to change g++ to MSVC (Visual C++ Compiler). So I configure settings.json for coderunner:

{
    "window.zoomLevel": 0,
    "code-runner.runInTerminal": true,
    "terminal.integrated.shell.windows": "cmd.exe",
    "code-runner.executorMap": {
        "cpp": "vcvars64.bat && cl.exe $fileName && del $fileNameWithoutExt.obj && cls && $fileNameWithoutExt.exe",
    },
    "files.autoSave": "afterDelay"
}

As you can see, I add path of vcvars64.bat to system PATH. It works, but after several runs I get next error:

Input line is too long.

I search for it and found that it is because CodeRunner run vcvars64.bat every time! So after several runs total path become too long:

"Input line is too long" error in BAT File

Restarting console clear it, but after several runs falls again.

Looks like I need to find some way to use vcvars64.bat only once but I don't know how!

Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102
  • Run `vsvars64.bat` in your command prompt first, then run coderunner from that command prompt (Visual Studio adds a shortcut to do this: Command Prompt for Visual Studio 2019 (or similar)) – Richard Nov 06 '19 at 15:16

2 Answers2

1


This is my setting.json

"code-runner.executorMap": {
    "cpp": "cd $dir && cl /EHsc $fileName && cls && $dir$fileNameWithoutExt.exe && del 
  $dir$fileNameWithoutExt.obj $dir$fileNameWithoutExt.exe",
},

And it's working as expected.

karthik oggu
  • 35
  • 11
  • 1
    Thank you for responce! It's work, but I need to use `vcvars64.bat` first time manually. How to use it automatically? In my example I use `vcvars64.bat` in `code-runner.executorMap` and it is a matter of error. – Mikhail_Sam Feb 18 '20 at 08:26
  • don't know y it's not working in cmd but it working fine in powerShell. – karthik oggu Feb 22 '20 at 18:34
1

change default shell to PowerShell in vs-code

"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",

then add this in setting.json file :

For PowerShell

"cpp": "cd $dir ; vcvars64.bat ;  cl /EHsc $fileName ; ./$fileNameWithoutExt.exe",
karthik oggu
  • 35
  • 11