microsoft / microsoft/vscode-cpptools
Header file with duplicate name but unique directory not identified by intellisense
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Bug Summary
I am using VSCode to work on source files from a large Visual Studio solution with many projects. Each project has its its own directory with various source files, and a subfolder for resource headers.
Solution/
├─ ProjectA/
│ ├─ Resources/
│ │ ├─ common.h
│ ├─ SourceA.cpp
├─ ProjectB/
│ ├─ Resources/
│ │ ├─ common.h
│ ├─ SourceB.cpp
ProjectA/Resources/common.h will only ever be referenced by source files within the ProjectA directory.
The issue with this is each of these resource headers has the same filename, so the intellisense database will only process the first one it finds. This is usually the first project folder alphabetically.
When running intellisense, on the above example, references to ProjectA/Resources/common.h by ProjectA/SourceA.cpp are resolved.
References to ProjectB/Resources/common.h by ProjectB/SourceB.cpp are not resolved and result in red squiggles with "identifier XYZ is undefined"
However when I click on the identifier in Source.B and select "go to definition" the extension correctly opens ProjectB/Resources/common.h and jumps to the selected identifier.
Configuration and Logs
This behavior is found in the default configurations. I have not been able to find a change to the configuration that alters this behavior.
Debug log diagnostics do not display anything unusual or useful.
Environment
- OS and Version: Win 11 25H2
- VS Code Version: 1.125.1 (issue identified on earlier versions)
- C/C++ Extension Version: 1.33.0 (issue identified on earlier versions)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported layout with duplicate Resources/common.h files in separate projects, then inspect the extension's IntelliSense diagnostics and debug logs while comparing ProjectA/SourceA.cpp with ProjectB/SourceB.cpp. Trace how the extension identifies and indexes headers when go-to-definition succeeds but identifiers remain unresolved. Done means both project-local headers are indexed and references resolve without red squiggles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100