VScode C/C++ debug

  • 一个文件:
    1 直接clang -o hello hello.c 编译,
    2 然后debug那里建立launch.json -> lab1 -> c++.. -> GDB.. -> clang
    3 注意必须在hello.cpp页面进行操作,因为参数有${fileDirname}这种,就是当前文件
    
  • 多个文件: 要调整tasks.json
    launch.json最后一行 “preLaunchTask”: “C/C++: clang build active file”, 这个 prelaunchtask需要调整,方法是自己建一个tasks.json
1 main menu, choose Terminal > Configure Default Build Task
2 Choose C/C++ clang++ build active file 建立tasks.json,
里面有"label": "C/C++: clang build active file",就是改这个了
3 args参数中"${file}"是当前文件,后面再加上其他cpp文件,比如"list.c",
3 press ⇧⌘B or from the Terminal main menu choose Run Build Task,编译当前文件
4 还是建立launch.json,不用改什么

https://code.visualstudio.com/docs/cpp/config-clang-mac#_reusing-your-c-configuration

  • 查看vscode变量:
    create a VSCode task to output the variable value to the console. For example, to see the resolved value for ${workspaceFolder}, you can create and run (Terminal > Run Task) the following simple ‘echo’ task in tasks.json:
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "echo",
      "type": "shell",
      "command": "echo ${workspaceFolder}"
    }
  ]
}

https://code.visualstudio.com/docs/editor/variables-reference

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值