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"对应。文章来源:https://www.toymoban.com/news/detail-617652.html
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",则是制定要运行或者调试的可执行文件文章来源地址https://www.toymoban.com/news/detail-617652.html
到了这里,关于vscode中task.json和launch.json的关系的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!