VScode 配置文件launch.json和tasks.json

分享下自己的:

20190808145748.jpg

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" ;


20190808143555.jpg

点击错误/警告提示找不到文件的可以参考


20190808141659.jpg

20190808141630.jpg

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++"                    
            }
    ]
 }

你可能感兴趣的:(VScode 配置文件launch.json和tasks.json)