赞
踩
前记:VScode C/C++ 开发环境搭建及代码运行参考另一篇文章:
Visual Studio Code -> VSCode 开发环境搭建 ---- C/C++ 开发环境搭建 及 代码运行(code runner 插件)
VSCode 开发环境搭建 ---- C 代码调试
平台:Windows 10
IDE:Visual Studio Code :VSCode
功能环境:C 代码调试环境
目录
严文年 -- 记于苏州
确认开发平台的系统信息:目前基于Windows 10 - 64位操作系统进行VSCode配置。
A. 创建代码调试使用的工作区:
A. 在创建的工作空间名称上单击鼠标右键,通过VScode打开工作空间:
B. VScode目录显示:
A. 新建文件,输入 C 代码:
B. 保存文件到创建好的工作区:
附:launch.json配置文件
- {
- // 使用 IntelliSense 了解相关属性。
- // 悬停以查看现有属性的描述。
- // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "name": "C Debug",
- "type": "cppdbg",
- "request": "launch",
- "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
- "args": [],
- "stopAtEntry": false,
- "cwd": "${workspaceFolder}",
- "environment": [],
- "externalConsole": false,
- "MIMode": "gdb",
- "miDebuggerPath": "D:\\SoftWare\\mingw64\\bin\\gdb.exe",
- "setupCommands": [
- {
- "description": "为 gdb 启用整齐打印",
- "text": "-enable-pretty-printing",
- "ignoreFailures": true
- }
- ],
- "preLaunchTask": "gcc.exe build active file"
- }
- ]
- }

附:tasks.json配置文件
- {
- // 有关 tasks.json 格式的文档,请参见
- // https://go.microsoft.com/fwlink/?LinkId=733558
- "version": "2.0.0",
- "tasks": [
- {
- "type": "shell",
- "label": "gcc.exe build active file",
- "command": "D:\\SoftWare\\mingw64\\bin\\gcc.exe",
- "args": [
- "-g",
- "${file}",
- "-o",
- "${fileDirname}\\${fileBasenameNoExtension}.exe"
- ],
- "options": {
- "cwd": "D:\\SoftWare\\mingw64\\bin"
- },
- "problemMatcher": [
- "$gcc"
- ],
- "group": "build"
- }
- ]
- }

1. 以上是使用VScode + code runner 调试 C代码的完整配置过程。
2. 关于VScode + code runner 对同一工作区的多个文件(.h,.c) 代码进行debug的配置:
见另一篇文章:Visual Studio Code -> VSCode 开发环境搭建 ---- 多个C文件链接调试(code runner 插件)。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。