Incorrect intelliSense errors depending on include order
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.
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.
Any updates? This has made IntelliSense useless for almost 1 year now...
/cc @bobbrow @sean-mcmanus
@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 .
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.
I don't know of a workaround. I asked in the internal issue if anyone knew.
Thanks. Please, let us know when you hear back from them.
Is there an update on this? The issue has been around for two years now, making development more difficult. @sean-mcmanus
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...
@mathiasgugg There's no update -- the internal VS is still open.
Hi @sean-mcmanus, hope you have a great day. Is there any activity/update on internal issue?
@hlvlad No. There's been no activity on the issue since the issue was first filed. It could use more upvotes to get prioritized.
I thought it was an intellisense internal issue. Where can we upvote it?
@g-arjones You can upvote this GitHub issue.