windows下vscode配置c/c++环境

事先的准备工作可以借助B站大佬的视频

可能他视频中用到的文件链接失效,我提前下载好了,存到网盘里了

链接:https://pan.baidu.com/s/1vw-CGImdTpDV-kQTMkb9TA 提取码:jbkj

因为视频稍微有些就远了,下面是我关于配置遇到的一些新问题:

打开上面链接和视频中出现的不一样,是下面这样的内容:

我们需要做的是,把花括号留下,内容删除。复制下面内容,细节我给大家改好了,直接用就行

"code-runner.executorMap": {

"javascript": "node",

"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",

"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && rm $dir$fileNameWithoutExt.exe",

"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && rm $dir$fileNameWithoutExt.exe",

"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

"php": "php",

"python": "python -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",

"vbscript": "cscript //Nologo",

"typescript": "ts-node",

"coffeescript": "coffee",

"scala": "scala",

"swift": "swift",

"julia": "julia",

"crystal": "crystal",

"ocaml": "ocaml",

"r": "Rscript",

"applescript": "osascript",

"clojure": "lein exec",

"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",

"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",

"racket": "racket",

"scheme": "csi -script",

"ahk": "autohotkey",

"autoit": "autoit3",

"dart": "dart",

"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",

"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",

"haskell": "runhaskell",

"nim": "nim compile --verbosity:0 --hints:off --run",

"lisp": "sbcl --script",

"kit": "kitc --run",

"v": "v run",

"sass": "sass --style expanded",

"scss": "scss --style expanded",

"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",

"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",

"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"

}

完事后记得保存。

之后再修改下,在terminal中运行,还有运行前保存等操作勾选上。

第二个问题:

在终端运行可能会提醒你说,powershell为旧版本,大家去官网下载一个新版本就行,然后重启vscode,就可以在终端运行了。

第三个问题:

如果勾选这个,意思是每次终端运行前都会删除之前的输出结果。

可能会这样子:

就感觉挺丑的,所以大家根据自己的需要,取消勾选后运行就是这样子:

虽然东西多了点,但是可以接受。

以上就是我的小经验,原本想写来给自己防止忘记,如果能帮到大家那更好啦。

经验分享 程序员 微信小程序 职场和发展