Open aaa45190 opened 3 weeks ago
@aaa45190 What is the definition of LOG or what can we use to for the repro?
@aaa45190 Also, what compiler are you using? I'm guessing gcc or clang?
@aaa45190 With #define LOG(args...)
and gcc I'm not getting an error.
@aaa45190 Also, you may want to try running C/C++: Reset IntelliSense Database in case that has incorrect "non-existent files" saved to it. And running C/C++: Log Diagnostics after opening the repro file and looking for anything unexpected.
I can provide another example to see if it's helpful base.h
class Base {
virtual int fun1() { return 0; }
};
derived.h
#include “base.h”
class D: public Base {
int fun1();
}
derived.c
#include “derived.h”
int D::fun1() { // Error Report Here: class "D" has no member "fun1" c/c++(135)
// something
return 0;
}
I have a problem that is maybe releated, because if i downgrade to 1.21.6, like @aaa45190 did, it is gone.
I get the following error message: pointer or reference to incomplete type is not allowed C/C++(833) But I directly include the file where the type is defined. I can open the file with "Go to Definition" without a problem. And when I open the file, where the type is defined, than the error goes away. But as soon as I close the file the error comes back.
It looks like as if he does not find the inlcuded file. But the directory with the included file is specified "includePath". Is there somewhere a log with the files he did find and added into the intellisense Database ?
I tried C/C++: Reset IntelliSense Database, but error still exist.
Environment: I',m using gcc. OS and Version: win11 VS Code Version: 1.9.42 C/C++ Extension Version: 1.22.10 If using SSH remote, specify OS of remote machine: debian 12
@aaa45190 The code you provided doesn't compile as written. It doesn't use the ASCII \"
character for the include statement and it's missing a semicolon after the class definition, and the file extension is .c, which may cause it to be associated with C instead of C++ by default. When I fix those issues, I don't get any errors:
@schattenmann80 Can you try running C/C++ Log Diagnostics when the error occurs and when the file with the type is opened and compare them? The TU used could be changing. Another thing to try is to set C_Cpp.intelliSenseCacheSize to 0 to make sure it's not an invalid cache bug. The TU could also be missing the type info if an include or define is incorrect. You may try running something like g++ -std=c++20 -I<includes> -D<defines> -E -dD <file>
to generate a preprocessed file (where the -I and -D are what are shown in the log diagnostics results). Or are you able to provide a repro sample code?
@aaa45190 The code you provided doesn't compile as written. It doesn't use the ASCII
\"
character for the include statement and it's missing a semicolon after the class definition, and the file extension is .c, which may cause it to be associated with C instead of C++ by default. When I fix those issues, I don't get any errors:@schattenmann80 Can you try running C/C++ Log Diagnostics when the error occurs and when the file with the type is opened and compare them? The TU used could be changing. Another thing to try is to set C_Cpp.intelliSenseCacheSize to 0 to make sure it's not an invalid cache bug. The TU could also be missing the type info if an include or define is incorrect. You may try running something like
g++ -std=c++20 -I<includes> -D<defines> -E -dD <file>
to generate a preprocessed file (where the -I and -D are what are shown in the log diagnostics results). Or are you able to provide a repro sample code?
I encountered a similar problem. I added "includePath": ["${workspaceFolder}/**"]
in . vscode/c_cpp_properties.json
. But in fact, when I use the #include in my . c
file, it can't find the header file, At the same time, I can't jump to the definition and find the symbol in the outline. This situation only happened after I recently upgraded the version.
environment: Version: win11 VS Code Version: 1.9.42 C/C++ Extension Version: 1.22.10
To set C_Cpp.intelliSenseCacheSize to 0 did not help.
If i run C/C++ Log Diagnostics than the difference is In the good case: The include file is pressend in "Translation Unit Mappings:" The last line ist Number of files parsed: .... In the bad case: The line "Number of files parsed:.." is missing The following is insted there: ------- Potential include path issues -------- Some headers exist in multiple locations. If IntelliSense is behaving incorrectly, try adding one of the alternate paths to the "includePath" in your configuration in c_cpp_properties.json to override the automatic path discovery for that header.
But the missing include is not in include path issues.
@schattenmann80 The missing include wouldn't necessarily need to be in the "include path issues" if one of those issues causes the wrong header to be used and then either parsing to fail catastrophically or for the include with the definition to be used. Is there any difference in the include paths that are logged for the TU? The translation unit mapping would only show the include file if the file were opened.
"Is there any difference in the include paths that are logged for the TU? " Yes the order is different, but only from the directory where the missing include is inside. But only the order of this one directory everything else is the same.
@sean-mcmanus I tried the cache, it did not help. I also tried C/C++ Log Diagnostics and running compile command, they still did not help. For some reason, I can not share my project repo. But I have something new to share with you, it may help.
base.h
and derived.h
are added in c_cpp_configures.json
with format ["path_to_pro/base", "path_to_pro/derived"]
b. When the Error occurs, if I open file base.h
, the Error in derived.c
will disappear. After the Error disappeared, if I closed the file base.h
, the Error would appear again a few minutes later.
c. It seems, the file base.h
can not be found if the file base.h
is not opened. Or looks like the file base.h
is removed from some records. @aaa45190 So you don't repro the issue with base.h/derived.h/derived.c with a small workspace? What does ["path_to_pro/base", "path_to_pro/derived"]
mean? Which property is that? includePath? Are you saying they're in different folders? Using C/C++: Log Diagnostics won't fix the issue, but it could show what source file is getting associated with base.h. They should be associated with the derived.c file and not some other file in your workspace. Also, are you sure all the files are getting processed as C++ and not C?
Environment
Bug Summary and Steps to Reproduce
Bug Summary: There are server files:
fa.h, fb.h, fb.cc fc.h, fc.cc
fa.h:
fb.h:
fc.h:
fc.cc:
The Report Error is c/c++(833), even the macro could be expanded. For same case, it works good in
C/C++ Extension Version: 1.21.6
, but in version 1.22.x will report error Currently I already rollback to 1.21.6Configuration and Logs
the log can not provide
Other Extensions
No response
Additional context
No response