-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
"Go to Definition" sometimes leads to declaration instead of definition #167
Comments
Hi @ZedOud. Please add a comment here that provides detailed instructions I can follow to reproduce the problem. Here is an example of the sort of instructions I need:
If I follow the above instructions, I am taken to the definition of Something to note is that the clangd C++ language server that provides the "context aware" features like "Go to Definition" for Arduino IDE falls back to the declaration when the definition is not available: An example of when the definition would not be available is when the implementation is in a precompiled object file. This is done in some cores and libraries in order to reduce the initial compilation time which might be quite considerable in the case of the very significant quantities of code that are present in some of the more advanced cores (e.g., Arduino Mbed OS boards) and libraries (e.g., Arduino_TensorFlowLite). There is also a "toggle" implemented that causes it to switch between the definition and declaration: I'm actually not experiencing that toggling behavior when following the steps I describe above. I consistently get the definition even when I trigger a "Go to Definition" repeatedly on the |
Hi @per1234
These were tested with the Uno selected. P.S. accidentally misclicked it as "closed" |
I don't know if I can provide any more information. It seems evident that most libraries, and all of those I've tried, move to the declaration. The only exception seems to be for the global namespace, which I'm not sure if that is what it is precisely called in Arduino C++, but I mean keywords like |
The problem seems to be specific to libraries. Here is a minimal reproduction: Sketch: #include <Foo.h>
void setup() {
foo();
}
void loop() {} Library:
void foo();
void foo() {} Trigger a "Go to Definition" ( But if you move |
Describe the problem
In the context menu that opens when you right-click on an Arduino IDE editor view, we have two references to "Definitions":
However, these options, respectively, bring you to the subject's declaration in the relevant header file or shows a preview of its declaration in the relevant header.
Rarely, though, a "declaration that is also a definition" might be seen in the header (to loosely quote [this reference])(https://learn.microsoft.com/en-us/cpp/cpp/declarations-and-definitions-cpp?view=msvc-170#definitions). Though, except for one-liners, this is rare in the header. We can safely state that this feature only, at least functionally, results in declarations.
I thought I was doing something incorrectly: something wrong with my board packages, or with my libraries. However this occurs many boards I tried, even with the Arduino Uno, and it occurs for the default libraries and other widely used libraries.
I figured I must be operating the feature incorrectly, as I assumed I should be able to reach the Definition.
After a few hours investigating this, and looking through the Issues, I can only conclude that this is a typo, as either:
Thank you for your time. I hope this minor bug can be resolved.
To reproduce
A context menu will open.
🐛 You are taken to the declaration of the symbol; not the definition as promised.
Expected behavior
I would expect to see a definition, not just a declaration, which would take me to a .cpp file instead of a .h file.
Arduino IDE version
2.2.2-nightly-20230916
Operating system
macOS
Operating system version
13.5.2
Additional context
Additional reports
Issue checklist
The text was updated successfully, but these errors were encountered: