VScode多文件编译/调试配置

之前都是在Visual Studio写C/C++,最近想换到VScode,折腾半天把launch.json和tasks.json配好了(虽然不懂为什么,但确实能用了),在此做个记录。

VScode配置C++环境参考资料:12

多文件参考资料:123

环境:win10

launch.json如下

复制代码
{
    "configurations": [
      {
        "name": "C/C++: g++.exe build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "E:\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          },
          {
            "description": "Set Disassembly Flavor to Intel",
            "text": "-gdb-set disassembly-flavor intel",
            "ignoreFailures": true
          }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
      }
    ],
    "version": "2.0.0"
  }

tasks.json如下

复制代码
{
    "tasks": [
      {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "E:\\mingw64\\bin\\g++.exe",
        "args": [
          "-fdiagnostics-color=always",
          "-g",
          "${workspaceFolder}/*.cpp",
          "-o",
          "${workspaceFolder}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
          "cwd": "${fileDirname}"
        },
        "problemMatcher": ["$gcc"],
        "group": {
          "kind": "build",
          "isDefault": true
        },
        "detail": "Task generated by Debugger."
      }
    ],
    "version": "2.0.0"
  }
相关推荐
q***046326 分钟前
[golang][MAC]Go环境搭建+VsCode配置
vscode·macos·golang
ZhongruiRao27 分钟前
vscode windows免密登录Linux服务器教程 解决设置后仍需要输入密码的问题
linux·服务器·vscode
阿阿阿阿里郎1 小时前
Vscode+STM32CubeMX+Cmake联合开发教
ide·vscode·编辑器
77wpa1 小时前
VS Code(Visual Studio Code)开发调试 C/C++ 工程配置
c++·vscode
vortex52 小时前
为什么我把VSCode换成了Code-Server
ide·vscode·编辑器
0和1的舞者3 小时前
《Maven 核心功能与仓库体系详解》
ide·maven·项目管理·仓库·依赖
AI_56783 小时前
从“插件装一堆”到“效率翻一倍”——IntelliJ IDEA的插件化开发革命
java·ide·intellij-idea
前讯焦点3 小时前
星图云开发者平台页面编辑器:提供系统全面的解决方案
编辑器
保持低旋律节奏4 小时前
linux——vim编辑器
linux·编辑器·vim
那些免费的砖4 小时前
Isle-Editor (岛屿编辑器) - 免费开源 Web 富文本编辑器,也支持 Notion 块编辑、MarkDown 语法,官方支持 Vue3 开箱即用
前端·编辑器·notion