首页 文章

运行c程序时的VsCode

提问于
浏览
1

这是我的VsCode的launch.json文件:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "C++ Launch (GDB)",                
        "type": "cppdbg",                         
        "request": "launch",                        
        "targetArchitecture": "x86",                
        "program": "${workspaceRoot}\\${fileBasename}.exe",                 
        "miDebuggerPath":"C:\\mingw-w64\\bin\\gdb.exe", 
        "args": [],     
        "stopAtEntry": false,                  
        "cwd": "${workspaceRoot}",                  
        "externalConsole": true,                  
        "preLaunchTask": "g++"                    
        }
]

这个如果我的tasks.json文件:

{
"version": "2.0.0",
"tasks": [
    {
        "label": "<TASK_NAME>",
        "type": "shell",
        "command": "make",
        // use options.cwd property if the Makefile is not in the project root ${workspaceRoot} dir
        "options": {
            "cwd": "${workspaceRoot}/<DIR_WITH_MAKEFILE>"
        },
        // start the build without prompting for task selection, use "group": "build" otherwise
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": false,
            "panel": "shared"
        },
        // arg passing example: in this case is executed make QUIET=0
        "args": ["QUIET=0"],
        // Use the standard less compilation problem matcher.
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["absolute"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
]}

他们之前和现在都没有工作过 . 当我运行任务终端时显示:

并且它正在构建:

然后当我调试(F5)程序时它显示如下:

请帮助我如何运行c程序 . 谢谢你的回答!

1 回答

  • 0

    您已配置了一个名为g的预启动任务,但没有该名称的任务 . 您需要将构建任务的名称更改为g .

    您只需要更改 label 的值以匹配tasks.json中任务的名称

相关问题