在设置里找到Coderunner选项,然后找到executorMap
点击 在 settings.json 中编辑 ,你将看到对不同语言的编译指令。
以下为本人设置,为Mac系统,指令有所不同,不过操作流程是一样的。
"code-runner.executorMap": {"javascript": "node","java": "cd $dir && javac $fileName && java $fileNameWithoutExt","c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","cpp": "cd $dir && clang++ $fileName -o $fileNameWithoutExt -g -std=c++14 -D LOCAL -Wall -fsanitize=undefined && $dir$fileNameWithoutExt","objective-c": "cd $dir && gcc -framework Cocoa $fileName -o -Wall $fileNameWithoutExt && $dir$fileNameWithoutExt","php": "php","python": "python3 -u","perl": "perl","perl6": "perl6","ruby": "ruby","go": "go run","lua": "lua","groovy": "groovy","powershell": "powershell -ExecutionPolicy ByPass -File","bat": "cmd /c","shellscript": "bash","fsharp": "fsi","csharp": "scriptcs",...}
推荐编译选项
-
-g
只有加了这个才能用 gdb 调试。
-
-Wall
包括但不限于警告未初始化、未使用变量。可以一定程度地减少低级错误
-
-O2
加速优化,可能有副作用。
-
-std=c++17
编译标准。当然后面这个数字可以改成别的。