我现在在ubuntu上使用vscode配置了一下c++的环境, 然后发现现在遇到数组下标越界的情况的时候,vsode不会报错
下面的是我的launch.json
和task.json
launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gdb调试",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main.out",
"args": [],
"cwd": "${workspaceFolder}",
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "cmake-build"
}
]
}
task.json
{
"tasks": [
{
"type": "cppbuild",
"label": "cmake-build",
"command": "cmake",
"args": [
"--build",
"build"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
ubuntu22.04LTS
vscode + cmake + gdb
达到一键就可以实现编译+运行+调试(已经实现)+段错误检测(未实现)
cmake的配置文件中添加-Wall参数