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 }
