【C/C++】VsCode调试配置tasks.json和launch.json

前段时间配大作业环境改了很多配置,发现tasks.json和launch.json经常令自己很迷惑。网上找的配置有时会有各种各样的问题,在此记录一下上学期配好的配置文件,日后有时间再详细研究研究

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build active file",
            "command": "D:\\newMinGW\\mingw64\\bin\\g++.exe",  
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\newMinGW\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,  
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\newMinGW\\mingw64\\bin/gdb.exe",  
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++.exe build active file"
        }
    ]
}
posted @ 2024-04-03 14:27  yichen111  阅读(239)  评论(0)    收藏  举报