VSCode配置C调试环境参考

一、launch.json
{
    // 使用 IntelliSense 了解相关属性。
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc.exe build active file"
        }
    ]
}
  1. 修改为"externalConsole": false时,采用集成终端调试。
  2. 采用外部终端调试时,修改以下两项可避免终端闪退:
 "program": "C:\\Windows\\system32\\cmd.exe"
 "args": ["/C","${fileDirname}\\${fileBasenameNoExtension}.exe","&","pause"]
二、tasks.json
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "shell",
			"label": "C/C++: gcc.exe build active file",
			"command": "C:\\mingw64\\bin\\gcc.exe",
			"args": [
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "${workspaceFolder}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			}
		}
	]
}
三、c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\mingw64\\bin\\gcc.exe",
            "cStandard": "c99",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}
  1. "cStandard"的可选值: “c89”, “c99”, “c11”, “c17”, “gnu89”, “gnu99”, “gnu11”, “gnu17”, “${default}”。
  2. "cppStandard"的可选值: “c++98”, “c++03”, “c++11”, “c++14”, “c++17”, “c++20”, “gnu++98”, “gnu++03”, “gnu++11”, “gnu++14”, “gnu++17”, “gnu++20”, “${default}”。
参考:
  1. vscode配置C调试环境(launch.json tasks.json setting.json)
  2. 绝对好使!VSCode for Mac调试C/C++配置lauch.json和tasks.json
  3. 40 VSCode下.json文件的编写——(1) linux/g++ (2).json中参数与预定义变量的意义解释
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值