microsoft / microsoft/vscode-cpptools

Add detection of linker errors to gcc problem matcher

Open
#10,383 4 comments 32 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request help wanted Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment:
  • OS and Version: Windows 10
  • VS Code Version: 1.74.3
  • C/C++ Extension Version: v1.13.9
  • If using SSH remote, specify OS of remote machine: CentOS 7.6
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:
  • Using the attached example below, run the default build task

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied tasks.json and main.cpp, then run the default build task with the $gcc problem matcher to reproduce the linker output. Trace how the matcher handles the reported file and line, and verify completion when the linker error appears in the Problems panel and highlights main.cpp line 5.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.