vscode c/c++ 调试

main.c

#include <stdio.h>
int main(int argc, char const *argv[])
{
    int a = 10;
    int b = 20;
    int c = a +b;
    printf("c = %d\n",c);
    return 0;
}

Makefile

# CC=g++
CC=clang
target: 
    $(CC) -g -o main main.c 
clean:
    rm main 

生成启动文件

image

 

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 main test",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/main",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb"
        }

    ]
}

打上断点就可以点启动了

image

 

posted on 2026-02-07 10:25  少杨  阅读(3)  评论(0)    收藏  举报