主要设置和json内容如下:
cpp_properties.json内容:
{"configurations": [ //C++ intellisense插件需要这个文件,主要是用于函数变量等符号的只能解析{"name": "Win32","includePath": ["${workspaceFolder}/**"],"browse":{//解析工作路径下的所有文件夹或者文件中的符号"path": ["${workspaceFolder}/**"]},"defines": ["_DEBUG","UNICODE","_UNICODE"],"compilerPath": "C:\\mingw64\\bin\\gcc.exe","cStandard": "c17","cppStandard": "gnu++17","intelliSenseMode": "windows-gcc-x64"}],"version": 4
}
lanuch.json内容(更改launch中的可执行文件路径,也可以调试makefile和cmake管理生成的项目)
{// 使用 IntelliSense 了解相关属性。// 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [ //launch.json主要用于调试程序{"name": "(gdb) 启动","type": "cppdbg", //注意这个地方,如果为gdb,遇到断点时可能变量的值显示不正确"request": "launch","program": "${workspaceFolder}/pointerTest.exe", //需要调试的可执行文件的路径"args": [],"stopAtEntry": false, //程序是否停在开始处"cwd": "${fileDirname}","environment": [],"externalConsole": false, //程序运行时是否新建终端,为false直接在vscode编辑器里面的终端显示"MIMode": "gdb","miDebuggerPath": "C:/mingw64/bin/gdb.exe", //gdb命令的路径,不指定路径程序可能会运行不正常"setupCommands": [ //gdb调试前需要执行的命令{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "将反汇编风格设置为 Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true},{"description": "忽略GDB中的SIGUSR1信号","text": "handle SIGUSR1 nostop noprint pass", //三个参数notop noprint pass在vscode中需要全部加上才能生效"ignoreFailures": true}]}]
}
task.json内容
{"tasks": [ //task.json用于编译程序时使用{"type": "cppbuild","label": "C/C++: gcc.exe 生成活动文件","command": "C:\\mingw64\\bin\\gcc.exe", //指定编译器的绝对路径"args": [ //编译器进行编译时的指定的参数:可进行额外的参数添加,如 "-std=c++11"、指定需要链接的库的路径"-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}],"version": "2.0.0"
}