vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Incorrect intelliSense errors depending on include order

Open HampusAdolfsson opened this issue 3 years ago • 13 comments

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.

HampusAdolfsson avatar Jul 05 '22 11:07 HampusAdolfsson

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.

Colengms avatar Jul 06 '22 19:07 Colengms

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

/cc @bobbrow @sean-mcmanus

g-arjones avatar Apr 11 '23 09:04 g-arjones

@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 .

sean-mcmanus avatar Apr 11 '23 19:04 sean-mcmanus

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.

g-arjones avatar Apr 12 '23 07:04 g-arjones

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

sean-mcmanus avatar Apr 13 '23 21:04 sean-mcmanus

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

g-arjones avatar Apr 14 '23 16:04 g-arjones

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

mathiasgugg avatar Mar 11 '24 16:03 mathiasgugg

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

Wastus avatar Mar 11 '24 16:03 Wastus

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

sean-mcmanus avatar Mar 11 '24 18:03 sean-mcmanus

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

hlvlad avatar Jun 28 '24 09:06 hlvlad

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

sean-mcmanus avatar Jun 29 '24 01:06 sean-mcmanus

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

g-arjones avatar Jun 29 '24 01:06 g-arjones

@g-arjones You can upvote this GitHub issue.

sean-mcmanus avatar Jun 29 '24 01:06 sean-mcmanus