汉扬编程 C语言入门 怎么将VSCode配置成专业的C语言开发环境,源代码+视频

怎么将VSCode配置成专业的C语言开发环境,源代码+视频

VSCode只是一个编写代码的辅助工具,支持所有主流的开发语言,但是每一种语言的编译器,调试器是不一样的,而VSCode本身也不带这些编译调试工具。因此,想要在VSCode里开发调试程序,必须配套安装相应语言的编译工具。下面以C语言开发为例给大家介绍(具体操作可参考我的视频vscode+mingGW的C语言开发环境)

Task编译配置从Terminal>Configure Task…进入,需要将“command”指定为你电脑上minGW的路径;"Label"值根据自己喜好设定。

{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "myGccTask", "command": "E:\\\\Program Files (x86)\\\\mingw-w64\\\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\\\mingw32\\\\bin\\\\gcc.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\\\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } } ] }全局编译器路径设定从左下角Manage>Setting>extensions>C/C++, edit insetting.json

同样需要修改"C_Cpp.default.compilerPath"的路径。

{ "C_Cpp.updateChannel": "Insiders", "cStandard": "c11", "intelliSenseMode": "gcc-x64", "C_Cpp.default.compilerPath": "E:\\\\Program Files (x86)\\\\mingw-w64\\\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\\\mingw32\\\\bin\\\\gcc.exe", "C_Cpp.commentContinuationPatterns": [ "/**" ], "git.autofetch": true, "git.path": "E:\\\\Program Files\\\\Git\\\\bin\\\\git.exe", "terminal.integrated.shell.windows": "C:\\\\Windows\\\\System32\\\\cmd.exe",}调试功能配置从Run>Open configurans进入,同样要修改“miDebuggerPath”的值。

注意:"preLaunchTask"的值要与Task中的“label”的值一致。

{ "version": "0.2.0", "configurations": [ { "name": "gcc my", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "E:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gdb.exe", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "myGccTask" } ] }Git路径的配置具体操作参见视频,参数参考本文02中“git.path”。

本文来自网络,不代表汉扬编程立场,转载请注明出处:http://www.hyzlch.com/cjia/6199.html

一整套英语重点复习资料向你砸来!期末考试高分过!高中生都要背

从事C语言工程师工作的朋友进

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

返回顶部