当前位置:   article > 正文

Visual Studio Code -> VSCode 开发环境搭建 ---- C 代码调试(code runner 插件)_vscode c代码调试

vscode c代码调试

前记:VScode C/C++ 开发环境搭建及代码运行参考另一篇文章:

Visual Studio Code -> VSCode 开发环境搭建 ---- C/C++ 开发环境搭建 及 代码运行(code runner 插件)


VSCode 开发环境搭建  ----  C 代码调试

平台:Windows 10

IDE:Visual Studio Code :VSCode

功能环境:C 代码调试环境


目录

1. 开发平台确认

【1】. Windows 系统信息

【2】. VScode 版本信息

【3】. VScode 需安装插件信息

2. 创建待调试 C 文件

【1】. 创建工作区

【2】. VScode加载工作区

【3】. 代码编写

3. 配置调试环境

【1】. launch.json文件配置

【2】. tasks.json文件配置

4. C 代码调试

5. 后记


严文年 -- 记于苏州

1. 开发平台确认

确认开发平台的系统信息:目前基于Windows 10 - 64位操作系统进行VSCode配置。

【1】. Windows 系统信息

【2】. VScode 版本信息

【3】. VScode 需安装插件信息

2. 创建待调试 C 文件

【1】. 创建工作区

A. 创建代码调试使用的工作区:

 

【2】. VScode加载工作区

A. 在创建的工作空间名称上单击鼠标右键,通过VScode打开工作空间:

B. VScode目录显示:

【3】. 代码编写

A. 新建文件,输入 C 代码:

B. 保存文件到创建好的工作区:

3. 配置调试环境

【1】. launch.json文件配置

附:launch.json配置文件

  1. {
  2. // 使用 IntelliSense 了解相关属性。
  3. // 悬停以查看现有属性的描述。
  4. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  5. "version": "0.2.0",
  6. "configurations": [
  7. {
  8. "name": "C Debug",
  9. "type": "cppdbg",
  10. "request": "launch",
  11. "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
  12. "args": [],
  13. "stopAtEntry": false,
  14. "cwd": "${workspaceFolder}",
  15. "environment": [],
  16. "externalConsole": false,
  17. "MIMode": "gdb",
  18. "miDebuggerPath": "D:\\SoftWare\\mingw64\\bin\\gdb.exe",
  19. "setupCommands": [
  20. {
  21. "description": "为 gdb 启用整齐打印",
  22. "text": "-enable-pretty-printing",
  23. "ignoreFailures": true
  24. }
  25. ],
  26. "preLaunchTask": "gcc.exe build active file"
  27. }
  28. ]
  29. }

【2】. tasks.json文件配置

附:tasks.json配置文件

  1. {
  2. // 有关 tasks.json 格式的文档,请参见
  3. // https://go.microsoft.com/fwlink/?LinkId=733558
  4. "version": "2.0.0",
  5. "tasks": [
  6. {
  7. "type": "shell",
  8. "label": "gcc.exe build active file",
  9. "command": "D:\\SoftWare\\mingw64\\bin\\gcc.exe",
  10. "args": [
  11. "-g",
  12. "${file}",
  13. "-o",
  14. "${fileDirname}\\${fileBasenameNoExtension}.exe"
  15. ],
  16. "options": {
  17. "cwd": "D:\\SoftWare\\mingw64\\bin"
  18. },
  19. "problemMatcher": [
  20. "$gcc"
  21. ],
  22. "group": "build"
  23. }
  24. ]
  25. }

4. C 代码调试

5. 后记

1. 以上是使用VScode + code runner 调试 C代码的完整配置过程。

2. 关于VScode + code runner 对同一工作区的多个文件(.h,.c) 代码进行debug的配置:

见另一篇文章:Visual Studio Code  -> VSCode 开发环境搭建  ----  多个C文件链接调试(code runner 插件)。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/214380
推荐阅读
相关标签
  

闽ICP备14008679号