Search code examples
visual-studio-codemingw-w64

How to set up VSCode's problem matcher with Linux-style gcc errors


I'm using VSCode on Windows 7 with MSYS2 + mingw-w64-x86_64-gcc + base-devel installed.

I've got tasks.json for my project running make command to build:

{
    "tasks": [
        {
            "type": "shell",
            "label": "build",
            "command": "make",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

The problem is GCC generates a error message in the following way:

src/src_file.cpp:773:59: error: comparison of integer expressions of different signedness

while the project path stored in $workspaceFolder variable is D:\myproject.

The real path to the file is D:\myproject\tools\src\src_file.cpp. I have no idea how to set up the problem matcher in this case. I suppose that Linux-style slashes affect the problem, but I'm not sure. I tried to set up regexp for the matcher, however I couldn't get it to work.

UPDATE:

Actually slashes and backslashes don't affect the result.


Solution

  • Use this problem matcher, use $gcc as base and define the file location

      "problemMatcher": {
        "base": "$gcc",
        "fileLocation": ["relative", "${workspaceFolder}/tools"]
      }
    

    Edit

    Removed the src because it is already part of the error message. (Did not spot it)