microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Add detection of linker errors to gcc problem matcher #10383

Open KarimAshraf1995 opened 1 year ago

KarimAshraf1995 commented 1 year ago

Environment:

Bug Summary:

$gcc problem matcher does not match linker errors. Trying to compile the example using standard g++ with -g flag will result in linker error with file and line info which should be matched.

To reproduce:

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile main file",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "main.cpp"
            ],
            "problemMatcher":"$gcc",
            "presentation": {
                "reveal": "always",
                "revealProblems": "always"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

main.cpp

extern void external_func();

int main()
{
    external_func();
    return 0;
}

The output of the task when I run it on my machine is /tmp/ccghmjfX.o: In function `main': /home/karim/test/main.cpp:5: undefined reference to `external_func()' collect2: error: ld returned 1 exit status

Expected behavior:

Linker error should be matched in the problems panel and highlighted in source file at line 5

Colengms commented 1 year ago

Hi @KarimAshraf1995.

Let's use this issue as a feature request to add linker errors to the gcc problem matcher.

Note that the gcc problem matcher is defined in full in our extension's package.json, currently as:

      {
        "name": "gcc",
        "source": "gcc",
        "owner": "cpptools",
        "fileLocation": [
          "autoDetect",
          "${cwd}"
        ],
        "pattern": {
          "regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
          "file": 1,
          "line": 2,
          "column": 3,
          "severity": 4,
          "message": 5
        }
      },
github-actions[bot] commented 1 year ago

This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.

github-actions[bot] commented 1 year ago

This feature request has received enough votes to be added to our backlog.