2

I would like to add the flag -std=gnu++17 when running vscode-code-runner.

I try to change the settings.json file using the settings tab in VSCode, but that does not seems to work. Here is the settings.json I used:

{
        "code-runner.executorMap": {
        "javascript": "node",
        "php": "C:\\php\\php.exe",
        "python": "python",
        "perl": "perl",
        "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
        "go": "go run",
        "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && g++ -std=gnu++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    },
    "window.zoomLevel": 1,
    "code-runner.saveFileBeforeRun": true

}

SSteve
  • 10,550
  • 5
  • 46
  • 72

2 Answers2

2

The "c" line of the setting.json file needs to be changed as "cpp":

"cpp": "cd $dir && g++ -std=gnu++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"

PS: Thanks to Jun Han @formulahendry for pointing it out.

0

If you are using code runner to run programs.

Edit Executor Map settings.

Add -std=c++17 to the following line and save the settings.json.

"cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

Thanks

Jenny Patel
  • 39
  • 1
  • 6