首页 > 解决方案 > vscode problemMatcher 无法识别任务编译器警告

问题描述

以下 Tasks.json 问题匹配器正则表达式应匹配以下典型警告。但事实并非如此。ctc W505:[“somedirectory/somefile.c”350/18] 隐式声明等等等等

问题是什么?我验证了内置解析器匹配 gcc 输出错误和警告。

谢谢,

萨蒂什·K

"tasks": [
        {
            "label": "build.bat",
            "type": "shell",
            "command": "build.bat",
            "problemMatcher": {
                "owner": "cpptools",
                "fileLocation": [
                    "relative",
                    "${env:PWD}"
                ],
                "pattern": {
                    "regexp": "^ctc W(\\d+): \\[\\\"(.*)\\\" (\\d+)\\\/(\\d+)\\] (.*)$",
                    "file": 2,
                    "line": 3,
                    "column": 4,
                    "message": 5
                }
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]

标签: visual-studio-codevscode-problem-matcher

解决方案


我无法让它工作。但是我通过 json escpare 运行了工作 regex101。它做了更多的斜线转义,结果如下:

"regexp": "^ctc W(\\d+): \\[\\\"(.*)\\\" (\\d+)\\/(\\d+)\\] (.*)$",

推荐阅读