microsoft / microsoft/vscode-cpptools
Incorrect intelliSense errors depending on include order
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung
Bug type: Language Service
Describe the bug
- OS and Version: Windows 10 21H2
- VS Code Version: 1.68.1
- C/C++ Extension Version: 1.10.7
- A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).
I've got the following two files, using IAR Systems standard library headers:
// main.cpp
#include <stdint.h>
#include <wchar.h>
#include <memory>
#include "header.hpp"
int main() {
auto b = ns::B(1);
}
// header.hpp
#pragma once
namespace ns {
class B {
public:
explicit B(const int& a) {}
};
}
In main.cpp, intelliSense incorrectly complains that the namespace ns does not exist:

If I open header.hpp, where ns is defined, and go back to main.cpp, the error disappears for a while. If I browse some other files for a while, the error reappears.
Interestingly, the problem only occurs when <memory> is included last of the standard library headers. Removing any of the includes or including <memory> earlier gets rid of the intelliSense error. main.cpp compiles correctly in all cases.
Steps to reproduce
Here is an example that reproduces the problem:
cpptools_errors_from_include_order_example.zip
It includes all the necessary files, including the c_cpp_properties.json and all required IAR standard library headers.
Simply open main.cpp and observe the intelliSense error.
Additional context
This may be related to https://github.com/microsoft/vscode-cpptools/issues/9170. The symptoms are similar, but the workaround of disabling the cache size limit did not work for me.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Öffne die bereitgestellte cpptools_errors_from_include_order_example.zip und untersuche main.cpp, header.hpp, c_cpp_properties.json und die IAR-Header; beginne damit, den falschen ns-Fehler zu reproduzieren, wobei zuletzt eingebunden wird. Als abgeschlossen gilt, dass IntelliSense für das bereitgestellte Beispiel nicht mehr meldet, dass ns nicht existiert, während das Projekt weiterhin korrekt kompiliert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp, typescript, vscode
- Bereich
- developer-experience, devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100