How to use vscode to debug C program under mac

  1. Xcode and vscode have been installed on the computer
  2. vscode has also installed the following plug-ins

clipboard.png


clipboard.png
]

:

clipboard.png

< hr >

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build hello world",
      "type": "shell",
      "command": "gPP",
      "args": [
        "-g",
        "main.cpp"
      ]
    }
  ]
}
< hr >

launch.json

{
  //  IntelliSense 
  // 
  // : https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(lldb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "enter program name, for example ${workspaceFolder}/a.out",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": true,
      "MIMode": "lldb"
    }
  ]
}
< hr >

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "cPP17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

ask what you need to do before you can write, debug and run C programs in vscode. Thank you ~

Jul.08,2021

"program": "${fileDirname} / ${fileBasenameNoExtension}",

Menu