デフォルトでは、コードランナーはmingw(g ++)用に構成されています。
_C ++ビルドツール(MSVCまたはcl.exe)用に構成するにはどうすればよいですか。_
"cpp": "\" MyFolder \ VC \ bin \ amd64 \ vcvars64.bat \ "&& cd $ dir && cl $ fileName /fe$fileNameWithoutExt.exe && $ dir $ fileNameWithoutExt.exe"、
ありがとう
これが私のために働いたsettings.jsonの内容です
`{
"files.autoSave": "afterDelay"、
"code-runner.runInTerminal":true、
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
"cpp": " \"C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/Tools/VsDevCmd.bat\" && cd $dir && cl $fileName /fe$fileNameWithoutExt.exe && $dir$fileNameWithoutExt.exe ",
}
} `
以下は、VC ++セットアップに関するVSCodeの公式ドキュメントから見た「/ Zi / EHsc / Fe:」引数を使用したセットアップです。 VsDevCmd.batのファイルパスは、VSのバージョンによって異なる場合があります。
"code-runner.executorMap": {
"cpp": " \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/Tools/VsDevCmd.bat\" && cd $dir && cl $fileName /Zi /EHsc /Fe:$fileNameWithoutExt.exe && $dir$fileNameWithoutExt.exe ",
}
これは、デフォルトシェルがPowerShellに設定されている場合の1つの作業です。 コマンドプロンプト(cmd.exe)では機能しません(ファイルVsDevCmd.batはcmd.exe用です)。 私はそれをC言語( "c")に設定しましたが、おそらくC ++( "cpp")でも機能するはずです。
"code-runner.executorMap": {
"c": "Import-Module \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell 00595aab; cd $dir; cl $fileName && del $fileNameWithoutExt.obj && Clear-Host && Start-Process pwsh -ArgumentList \"-Command &{.\\$fileNameWithoutExt; pause}\"",
PowerShellのコマンドライン:
Import-Module \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell 00595aab
Developer PowerShell for VS 2019Windowsの[スタート]メニューのショートカットから[プロパティ]-> [ターゲット]内に抽出されました。 すべてのEnter-VsDevShellには独自のID番号があることにください。 あなたはあなた自身のものを使わなければなりません。
cmd.exeのコマンドライン:
\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/Tools/VsDevCmd.bat\"
VS 2019 Windowsスタートメニューショートカットの
最も参考になるコメント
これが私のために働いたsettings.jsonの内容です
`{
"files.autoSave": "afterDelay"、
"code-runner.runInTerminal":true、
} `