vscode配置C语言打断点

搞了半天,也不知道为什么,不能打断点,后来就可以了。

1,VSCODE启动要管理员启动。

launch.json文件内容

{

"version": "0.2.0",

"configurations": [

{

"name": "(Windows) Launch",

"type": "cppvsdbg",

"request": "launch",

"program": "cmd",

"preLaunchTask": "echo",

"args": [

"/C",

"{fileDirname}\\\\{fileBasenameNoExtension}.exe",

"&",

"echo.",

"&",

"pause"

],

"stopAtEntry": false,

"cwd": "${workspaceFolder}",

"environment": [],

"externalConsole": true

},

{

"name": "(gdb) Launch",

"type": "cppdbg",

"request": "launch",

"program": "{workspaceFolder}/{fileBasenameNoExtension}.exe",

"args": [],

"stopAtEntry": false,

"cwd": "${workspaceFolder}",

"environment": [],

"externalConsole": true,

"MIMode": "gdb",

"miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe", // 自己电脑的gdb

"preLaunchTask": "echo", //这里和task.json的label相对应

"setupCommands": [

{

"description": "Enable pretty-printing for gdb",

"text": "-enable-pretty-printing",

"ignoreFailures": true

}

]

}

]

}

tasks.json内容

{

// See https://go.microsoft.com/fwlink/?LinkId=733558

// for the documentation about the tasks.json format

"version": "2.0.0",

"tasks": [

{

"label": "echo",

"type": "shell",

"command": "gcc",

"args": [

"-g",

"${file}",

"-o",

"${fileBasenameNoExtension}.exe",

"-fexec-charset=GBK" //解决中文乱码

]

}

],

"presentation": {

"echo": true,

"reveal": "always",

"focus": false,

"panel": "shared",

"showReuseMessage": true,

"clear": false

}

}

保存下。然后就可以了

相关推荐
叫我辉哥e15 小时前
### 技术文章大纲:C语言造轮子大赛
c语言·开发语言
你知道“铁甲小宝”吗丶6 小时前
VSCode使用Claude Code(MCP服务)
vscode·ai·ai编程
进击的小头8 小时前
行为型模式:策略模式的C语言实战指南
c语言·开发语言·策略模式
shishi5219 小时前
trae重装后,无法预览调试弹窗报错的解决方案
ide·计算机视觉·语言模型
爱编码的小八嘎9 小时前
C语言对话-5.通过任何其他名字
c语言
定偶11 小时前
C语言入门指南
c语言·开发语言
小皮每天进步一点点12 小时前
IDEA找不到源码
java·ide·intellij-idea
的卢马飞快12 小时前
【C语言进阶】给数据一个“家”:从零开始掌握文件操作
c语言·网络·数据库
我能坚持多久12 小时前
D17—C语言结构体详解:从声明、对齐到位段应用
c语言·开发语言
willingli12 小时前
c语言经典题目 91-100
c语言