-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"identifier is undefined" despite being found (only Linux/gcc, not macOS) #7326
Comments
Yes, it affects those macros only. |
I've filed an internal bug against our shared VS parser (with our internal repro). Hopefully they'll be able to fix it soon. |
Thanks for the update! |
I'm also seeing this issue on linux. All #defines in a .hpp header file and then included into another file will be resolved but then show the undefined error as @slhck reported. |
We believe this is fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.4.0-insiders2 |
Yes, this is fixed now, thanks! |
Actually, no, I am still seeing this issue with 1.4.0-insiders2 … |
Then it sounds like it's a different issue you're hitting. I think we may need some sort of isolated repro. You could try setting C_Cpp.intelliSenseCacheSize to 0 in case it's a bug with that caching. |
Well, one other thing to check is to go the definition on the macro that isn't defined and see if there are any IntelliSense errors reported or if the define is in an inactive region. Another potential thing to try is running |
Thanks for the suggestions! There are no errors in the macro itself. The errors disappeared when I turned off the cache by setting I first didn't see it in my user settings and had to check in the settings tab for the remote context. I turned the cache back on and the errors came back. |
Here I am having the same problem, and it was not fixed in 1.4.0. In version prior to 1.3.0 it was working.
In user.c file I have:
In board_config.h:
And in port.h:
Lastly there is a bunch of definitions for PORT_GROUPS depending on which of the following header files was included in a file called "samd21.h" that port.h depend on: And the right header to include is "samd21g18a.h" as "SAMD21G18A" was defined in c_cpp_properties.json c_cpp_properties.json:
The problem: I get the message : "PORTA" is undefined, despite the fact that in samd21.h it knows which file to include correctly. And with ctrl+click I can go to the right definition. With this same program and cpp_configuration it was working in previous versions. And I didn't receive this problem message Also, even though i also tried to set |
Thanks for confirming this and providing a simpler example! My guess is that in my case the error only disappeared when I reset the cache because it hadn't yet fully analyzed the sources yet (it's a bigger project). |
Okay, I'll see if I can repro it... |
Disabling the cache also fixes it for me. The first time the parser runs, the defines are found correctly, but as soon as I edit the file they are lost which does indicate a cache issue. |
I'm still not able to repro this. Is anyone able to provide a sample repro project? |
I'll try to set up a self contained example next week once I'm back at the Linux machine. |
I've made a self contained example for the issue I had observed. While I was making the simplifications for the example, I found that probably my issue arises from the fact that my project had 2 files named "port.h". Before making this example I didn't see this error. The project can compile without errors, version < 1.3.0 of the extension showed no errors, and ctrl + click can still find the right file, even if there is 2 with the same name. Maybe user "slhck" problem is different. Anyway, here is the link for the repo where I put the example : https://github.com/marcoabensur/identifier-undefined-issue The main.c file is inside src folder. |
@marcoabensur Your issue is "by design" and fixed by setting a non-recursive include path. The "**" (recursive include) path is choosing a different port.h path due to the name conflict so you need to specify a non-recursive path to take precedence. Another alternative to try would be to use the Makefile Tools extension and set |
Thank you! |
I think I will not be able to reproduce this. Most probably it is caused by the logging library being included twice, once in a library and once in the main executable, which is not a good design anyway. I'm closing this for now and will come back if I can reliably reproduce this. |
Type: LanguageService
Describe the bug
I have a project using the
loguru
library which I compile with meson. Theinclude
directory contains:In my C++ file, I add:
and use the function
LOG_S
, e.g.LOG_S(INFO) << "Connected to Redis server at " << host << ":" << port;
Under Linux, connected to a remote server, it shows the following error:
Under macOS, this error does not appear! Both are using the same settings and meson config.
What is interesting is that this used to work on both machines, so perhaps it was related to a recent change. I haven't changed any build or include settings.
Also, it is apparently able to resolve the definition of the function, but still shows the error? (See screenshot.)
I have tried applying latest updates and reloading the respective VS Code window.
I have tried creating a new test file, but there, the error does not appear, so I cannot really provide a reproducible example.
Details
c_cpp_properties.json
:compile_commands.json
:Logs
The text was updated successfully, but these errors were encountered: