Mac VSCode C/C++ 调试配置

本文详细介绍了如何使用VSCode进行C/C++项目的配置,包括c_cpp_properties.json文件中对编译器路径、标准及智能感知模式的设置;launch.json文件中的调试配置,如指定调试程序路径及预编译任务;以及tasks.json中的编译命令配置。

c_cpp_properties.json:

{
	"version": 4,
	"configurations": [
    	{
        	"name": "Mac",
        	"includePath": [
            	"${workspaceFolder}/**"
        	],
        	"defines": [],
        	"macFrameworkPath": [
        	"/library/developer/commandlinetools/library/frameworks" //(主要)
        	],
        	"compilerPath": "/usr/bin/clang",
        	"cStandard": "c11",
        	"cppStandard": "c++17",
        	"intelliSenseMode": "clang-x64",
        	"compileCommands": "${workspaceFolder}/build/compile_commands.json",
        	"configurationProvider": "ms-vscode.cmake-tools"
    	}
	]
}

launch.json

{
	"version": "0.2.0",
	"configurations": [
		{
  		"name": "clang++ - Build and debug active file", // 配置名称
  		"type": "lldb", // 配置类型
  		"request": "launch", // 请求配置类型,launch或者attach
  		"program": "${workspaceFolder}/build/ProjectName", // 进行调试程序的路径(主要)
  		"args": [], // 传递给程序的命令行参数,一般为空
  		"cwd": "${workspaceFolder}", // 项目目录
  		"preLaunchTask": "clang++ build active file" //每次调试前会自动编译
		}
	]
}

tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
  		"type": "shell",
  		"label": "clang++ build active file", //任务名
  		"command": "cd ./build ;cmake ../ ;make", //编译命令,更改(主要)
  		"args": [],
  		"options": {
    	"cwd": "${workspaceFolder}"
  		},
  		"problemMatcher": [
    		"$gcc"
  		],
  		"group": {
    		"kind": "build",
    		"isDefault": true
  			}
		}
	]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

M2_Bono

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值