分享下自己的:
tasks.json
{
"version": "2.0.0",
"command": "g++",
//可执行文件与源文件同一目录下
"args": ["-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
其中 "fileLocation": 应设置成"absolute" ;
点击错误/警告提示找不到文件的可以参考
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"miDebuggerPath":"D:\\mingw64\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": true,
"preLaunchTask": "g++"
}
]
}