launch.json
1 {
2 "version": "0.2.0",
3 "configurations": [
4 {
5 "name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示
6 "type": "cppdbg", // 配置类型,这里只能为cppdbg
7 "request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
8 "program": "${workspaceRoot}/${fileBasenameNoExtension}.o",// 将要进行调试的程序的路径
9 "args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可
10 "stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
11 "cwd": "${workspaceRoot}",// 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
12 "environment": [],
13 "externalConsole": true,// 调试时是否显示控制台窗口,一般设置为true显示控制台
14 "MIMode": "gdb",
15 "preLaunchTask": "g++", // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
16 "setupCommands": [
17 {
18 "description": "Enable pretty-printing for gdb",
19 "text": "-enable-pretty-printing",
20 "ignoreFailures": true
21 }
22 ]
23 }
24 ]
25 }
tasks.json
1 // https://code.visualstudio.com/docs/editor/tasks
2 {
3 "version": "2.0.0",
4 "command": "g++",
5 "args": ["-g","${file}","-o","${fileBasenameNoExtension}.o", "-std=c++17"], // 编译命令参数
6 "problemMatcher": {
7 "owner": "cpp",
8 "fileLocation": ["relative", "${workspaceRoot}"],
9 "pattern": {
10 "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
11 "file": 1,
12 "line": 2,
13 "column": 3,
14 "severity": 4,
15 "message": 5
16 }
17 }
18 }
来源:oschina
链接:https://my.oschina.net/u/4346195/blog/3499565