Linux下VSCodeC++程序相应的配置说明

VScode C++程序配置文档

首先给一下大佬的链接:https://www.jianshu.com/p/2700f2b93b14
然后记录一下自己的配置文档

注释的那个每次使用要修改,而下面的那个无需修改
  1. tasks.json
// {
//     "version": "2.0.0",
//     "tasks": [
//         {
//             "label": "build",
//             "type": "shell",
//             "command": "g++",
//             "args":[
//                 "-g","test.cpp","-o","test"
//             ],
//             "group": {
//                 "kind": "build",
//                 "isDefault": true
//             }
//         }
//     ]
// }
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build", //相当与名字,与后面launch.json中preLaunchTask参数要保持一致
            "type": "shell",
            "command": "g++", 
            "args": [     //编译所需要的参数,包括编译方式,源文件,和生成的可执行文件
                "-g",
                "-Wall",
                "-std=c++17",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "presentation": {   //控制终端显示
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": true
            },
        },
        {
            "label": "run",
            "type": "shell",
            "dependsOn": ["build"], //依赖的配置,运行之前需要编译链接形成可执行文件
            "command": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "presentation": {   //控制终端显示
                "echo": false,  // 执行命令是否输出到集成终端
                "reveal": "always",
                "focus": false,
                "panel": "shared", //控制是否共享面板
                "showReuseMessage": false, //是否显示"终端终端将被重用,是否显示"的提示
                "clear": true  //执行任务前是否清除终端
            },
            //"problemMatcher": [],
            "group": {           
                "kind": "test", 
                "isDefault": true
            }
        }
    ]
}
  1. launch.json
// {
//     "version": "0.2.0",
//     "configurations": [
//         {
//             "name": "(gdb) Launch",
//             "type": "cppdbg",
//             "request": "launch",
//             "program": "${workspaceFolder}/test",
//             "args": [],
//             "stopAtEntry": false,
//             "cwd": "${workspaceFolder}",
//             "environment": [],
//             "externalConsole": true,
//             "MIMode": "gdb",
//             "preLaunchTask": "build",
//             "setupCommands": [
//                 {
//                     "description": "Enable pretty-printing for gdb",
//                     "text": "-enable-pretty-printing",
//                     "ignoreFailures": true
//                 }
//             ]
//         }
//     ]
// }
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}", //程序可执行文件的路径
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}", 
            "environment": [],
            "externalConsole": false, //设为false时使用集成终端,true为外置终端
            "linux": {
                "MIMode": "gdb",
                "miDebuggerPath": "/usr/bin/gdb"
            },
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe"//windows系统下要更新相应的路径
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build"
        }
    ]
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值