vscode中task.json和launch.json的关系

tasks.json

复制代码
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "dog",
            "type": "shell",
            "command": "g++",
            "args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]	//相当于 g++ -g main.cpp -std=c++11 -o main.out
        }
    ]
}

launch.json

复制代码
{    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,	//如果不要窗口弹出,在ide中显示,就设置成 false
            "MIMode": "gdb",
            "preLaunchTask": "dog",   //表示预先生成一个中间文件,用于g++运行
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

坐标的label要跟 右边的 "preLaunchTask"对应。

"program": "{workspaceFolder}/{fileBasenameNoExtension}.out",则是制定要运行或者调试的可执行文件

相关推荐
Jayyih1 小时前
嵌入式系统学习Day35(sqlite3数据库)
数据库·学习·sqlite
得意霄尽欢3 小时前
Redis之底层数据结构
数据结构·数据库·redis
hsjkdhs4 小时前
MySQL 数据类型与运算符详解
数据库·mysql
爱吃烤鸡翅的酸菜鱼5 小时前
【Redis】常用数据结构之Hash篇:从常用命令到使用场景详解
数据结构·数据库·redis·后端·缓存·哈希算法
ZKY_245 小时前
【VsCode】离线状态下安装插件
vscode
李少兄5 小时前
IntelliJ IDEA 启动项目时配置端口指南
数据库·sql·intellij-idea
NineData5 小时前
NineData云原生智能数据管理平台新功能发布|2025年8月版
数据库·mongodb·云原生·数据库管理工具·ninedata·数据库迁移·数据复制
白云如幻5 小时前
【Java】QBC检索和本地SQL检索
java·数据库·sql
勘察加熊人6 小时前
python将pdf转txt,并切割ai
数据库·python·pdf
不良人天码星6 小时前
Redis单线程模型为什么快?
数据库·redis·缓存