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"
  }
相关推荐
eqwaak01 小时前
科技信息差(8.26)
大数据·开发语言·人工智能·编辑器
weixin_541299944 小时前
VSCode: 从插件安装到配置,如何实现 Ctrl+S 保存时,完全按照 .eslintrc.js 中的 ESLint 规则自动格式化代码
javascript·ide·vscode
天籁晴空6 小时前
vscode 配置 + androidStudio配置
vscode·uni-app·vue
会说话的吹风机6 小时前
五、VSCODE SSH连接linux服务器免密登录
服务器·vscode·ssh
半路程序员6 小时前
autojs连接vscode失败:failed to connect to /192.168.xxx.xxx
ide·vscode·编辑器
御龙冀人7 小时前
解决VSCode无法下载服务器端 Server问的题
服务器·vscode·ssh
全栈小51 天前
【AI编程】如何快速通过AI IDE集成开发工具来生成一个简易留言板系统
ide·人工智能·ai编程
猿饵块1 天前
vscode--快捷键
ide·vscode·编辑器
404Clukay1 天前
在VSCode中配置.NET项目的tasks.json以实现清理、构建、热重载和发布等操作
vscode·json·.net
蓝黑20201 天前
VSCode远程连接阿里云ECS服务器
服务器·vscode·阿里云