Vscode-code-runner: C ++ビルドツール(MSVC)のコードランナーを構成する

作成日 2018年07月13日  ·  5コメント  ·  ソース: formulahendry/vscode-code-runner

デフォルトでは、コードランナーはmingw(g ++)用に構成されています。

_C ++ビルドツール(MSVCまたはcl.exe)用に構成するにはどうすればよいですか。_

fyi question

最も参考になるコメント

これが私のために働いた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 ",
}

} `

全てのコメント5件

"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.batcmd.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スタートメニューショートカットの

このページは役に立ちましたか?
0 / 5 - 0 評価

関連する問題

StayFoolisj picture StayFoolisj  ·  5コメント

rickmed picture rickmed  ·  4コメント

emadb picture emadb  ·  5コメント

rana picture rana  ·  5コメント

ElektroStudios picture ElektroStudios  ·  4コメント