microsoft / microsoft/vscode-cpptools

Add missing include should prioritize the header with the class definition over headers with only a forward declaration (VS:1906590)

Open
#11,703 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Add '#include' Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Set up a project thusly:

Header.h
class Foo; // just forward declaration

Header2.h
class Foo {}; // the definition

Source.cpp
Foo foo;

Actual:
In the current product, Foo in cpp file should squiggle with "undefined" error and hovering over it offers both headers as suggestions.

Expected:
The suggested includes should be only Header2.h (to bring the full definition)

This should be addressed in VS and VS Code

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

Reproduce the case with Header.h, Header2.h, and Source.cpp, where Header.h only forward-declares Foo and Header2.h defines it. Verify the include suggestions produced for Source.cpp; done means only Header2.h is suggested, consistently in VS and VS Code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.