1.launch.json文件(固定即可):
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}]
}]
}
2.settiong.json文件(固定即可)
{
"files.associations": {
"array": "c",
"atomic": "c",
"*.tcc": "c",
"cctype": "c",
"chrono": "c",
"clocale": "c",
"cmath": "c",
"condition_variable": "c",
"cstdarg": "c",
"cstdint": "c",
"cstdio": "c",
"cstdlib": "c",
"cstring": "c",
"ctime": "c",
"cwchar": "c",
"cwctype": "c",
"deque": "c",
"unordered_map": "c",
"unordered_set": "c",
"vector": "c",
"exception": "c",
"fstream": "c",
"functional": "c",
"initializer_list": "c",
"iomanip": "c",
"iosfwd": "c",
"iostream": "c",
"istream": "c",
"limits": "c",
"mutex": "c",
"new": "c",
"ostream": "c",
"numeric": "c",
"ratio": "c",
"sstream": "c",
"stdexcept": "c",
"streambuf": "c",
"system_error": "c",
"thread": "c",
"cinttypes": "c",
"tuple": "c",
"type_traits": "c",
"utility": "c",
"typeinfo": "c",
"cstddef": "c",
"algorithm": "c",
"iterator": "c",
"map": "c",
"memory": "c",
"memory_resource": "c",
"optional": "c",
"random": "c",
"string": "c",
"string_view": "c",
"bit": "c",
"stdlib.h": "c"
}
}
3.task.json文件(根据需要自定义)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell", // 表示新建一个shell展示结果
"command":"gcc", // "command": "g++", 表示使用的编辑器,也可为g++编译器
"args":["${file}","-g","-o","${fileBasenameNoExtension}.out","-I.","-lhs","-L."] // gcc后面跟的编译参数信息,语法就是gcc的参数语法,需要时添加对应编译即可,必须加-g参数,不然vscode无法进入调试功能
}
]
}