microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Incorrect intelliSense errors depending on include order #9540

Open HampusAdolfsson opened 2 years ago

HampusAdolfsson commented 2 years ago

Bug type: Language Service

Describe the bug

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.

Colengms commented 2 years ago

Hi @HampusAdolfsson . Thanks for reporting this. I believe I'm able to repro the same issue using VS. (cpptools shares the same IntelliSense implementation as VS). I've opened an issue against VS internally.

g-arjones commented 1 year ago

Any updates? This has made IntelliSense useless for almost 1 year now...

/cc @bobbrow @sean-mcmanus

sean-mcmanus commented 1 year ago

@g-arjones It hasn't been fixed yet. There were some recent questions/activity on the issue, but I don't know if a fix could be expected soon or not. It's internal issue 1567142 .

g-arjones commented 1 year ago

Is there anything I can do to workaround/avoid having this issue? Most of my projects are affected so I'm stuck with the Tag Parser... Kinda disappointing to hear that.

sean-mcmanus commented 1 year ago

I don't know of a workaround. I asked in the internal issue if anyone knew.

g-arjones commented 1 year ago

Thanks. Please, let us know when you hear back from them.

mathiasgugg commented 7 months ago

Is there an update on this? The issue has been around for two years now, making development more difficult. @sean-mcmanus

Wastus commented 7 months ago

If you are using IAR, then it might be worthwhile to check out the VS Code Extension by IAR: iarsystems.iar-build and iar-debug.

Not saying this shouldn't be fixed because it's probably not an issue only for IAR...

sean-mcmanus commented 7 months ago

@mathiasgugg There's no update -- the internal VS is still open.

hlvlad commented 3 months ago

Hi @sean-mcmanus, hope you have a great day. Is there any activity/update on internal issue?

sean-mcmanus commented 3 months ago

@hlvlad No. There's been no activity on the issue since the issue was first filed. It could use more upvotes to get prioritized.

g-arjones commented 3 months ago

I thought it was an intellisense internal issue. Where can we upvote it?

sean-mcmanus commented 3 months ago

@g-arjones You can upvote this GitHub issue.