microsoft / microsoft/vscode-cpptools

Incorrect intelliSense errors depending on include order

Aperta
#9,540 13 commenti 13 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Language Service more votes needed Visual Studio
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

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:
image
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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Apri il file cpptools_errors_from_include_order_example.zip fornito e ispeziona main.cpp, header.hpp, c_cpp_properties.json e gli header IAR; inizia riproducendo il falso errore relativo a ns con incluso per ultimo. Il lavoro è completato quando IntelliSense non segnala più che ns non esiste per l’esempio fornito, mentre il progetto continua a compilare correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, typescript, vscode
Ambito
developer-experience, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.