Mac OS下使用VS Code对C++程序进行debug的配置

我的task.json和launch.json配置都是最基础的,仅仅几句不同,目前来说对我够用

在你的task.json文件里,如果要使用调试,编译参数就选-g,最后附上我的task.json文件(c++)

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "g++",//这里根据自己编译器改
            "args": [
                "-g",//调试程序必须设置的参数
                "main.cpp"
            ]
        }
    ]
}

以及对应的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": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",//这里删掉了没用的提示部分
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb",
            "preLaunchTask": "build"//这个可以在点击调试的时候自动编译一次你的代码(省事)
        }
    ]
}
    [VSCODE官方C++文档地址](https://code.visualstudio.com/docs/languages/cpp)

你可能感兴趣的:(C++,VSCODE,MACOS,C++,DEBUG)