我在 Windows 上使用 CodeRunner for VSCode,所以我需要将 g++ 更改为 MSVC(Visual C++ 编译器)。所以我settings.json
为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"
}
如您所见,我将 vcvars64.bat 的路径添加到系统 PATH 中。它可以工作,但是经过几次运行后,我得到下一个错误:
输入行太长。
搜索了一下,发现是因为CodeRunner每次都运行vcvars64.bat!所以经过几次运行后,总路径变得太长:
重新启动控制台清除它,但几次运行后再次下降。
看起来我需要找到一些vcvars64.bat
只使用一次的方法,但我不知道怎么做!