Tom Forest
Tom Forest

Reputation: 3

Problem in VSCode "$gcc" problem matcher to recognize file path in C++ compiler error reports

I have just set my launch.json and tasks.json as the tutorial on the Internet said. But when I pree F5 compile and find some errors, I cannot click the red words "errors" showed in the "Problems". Description

If I click, the information will be: Description

Anyone can help me?


task.json

{
    // https://go.microsoft.com/fwlink/?LinkId=733558
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build active file",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

Upvotes: 0

Views: 10860

Answers (1)

rioV8
rioV8

Reputation: 28613

The problem is the "$gcc" problem matcher defined in ms-vscode.cpptools-0.XX.0 extension.

It is the same problem matcher as mentioned in the Task documentation about problem matchers.

This matcher uses relative paths. But MinGW with g++ v8 uses absolute file paths in the error when the source file is supplied with absolute file path in the args property of the task.

Solution is to modify the "$gcc" problem matcher and use absolute file path.

      "problemMatcher": {
        "base": "$gcc",
        "fileLocation": "absolute"
      },

Upvotes: 3

Related Questions