mac下如何使用vscode调试C程序

  1. 电脑已经安装了Xcode、vscode
  2. vscode也已经安装了如下插件

clipboard.png

每次点击调试的时候,总是出现这个界
clipboard.png
]

本人项目文件情况如下:

clipboard.png


tasks.json

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

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"
    }
  ]
}

c_cpp_properties.json

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

请教下需要怎么弄,才可以在vscode里面编写 并且调试、运行C程序,谢谢~

阅读 5.1k
1 个回答
新手上路,请多包涵

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题