1.问题描述cao
1.1 Vscode调试C代码时候,报错。
2.解决办法
1.2 编译后查看终端窗口,检查代码中有无语法错误。
1.3 检查报错提示,是否与配置文件有关。
1.4与参考配置对比。
3.参考配置
3.1请注意注释中的提示信息。
3.2调试配置:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\TDM-GCC-32\\bin\\gdb.exe",/*修改为你自己的安装路径*/
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "tast gcc"/*和任务配置文件中label中的内容要一致*/
}
]
}
3.3任务配置:
{
"tasks": [
{
"type": "cppbuild",
"label": "tast gcc",
"command": "C:\\TDM-GCC-32\\bin\\gcc.exe",/*修改为你自己的安装路径*/
"args": [
//"-fdiagnostics-color=always",
"-g",
"${fileDirname}/*.c",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}