Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » error of "Open declaration" (find declaration of function goes wrong)
error of "Open declaration" [message #673741] Tue, 24 May 2011 15:27 Go to next message
jin huang is currently offline jin huangFriend
Messages: 1
Registered: May 2011
Junior Member
Build Identifier: eclipse 3.6.0

In a function of c code, when local variable has the same name as another
function A called in this function, if we check the method A's declaration by
clicking "Open declaration", it show the declaration of the local variable, but
not the declaration of function A.

Reproducible: Always

Steps to Reproduce:
when we have the follow source code, in which a local variable has the same
name as a function called,

----------------------------------
1 int methodA(int a, int b){
2 return a+b;
3 }
4
5
6 int method41(int a, int b){
7 int methodA = 2;
8 return methodA(a,b);
9 }
10
11 int method42(int a, int b){
12 return methodA(a,b);
13 }
----------------------------------

if we right click on the function reference "methodA(...)" in line 8, and click
"Open declaration" to get its declaration, eclipse will show you the
declaration "int methodA = 2" in line 7, which is a error.


Then, I use eclipse's "c/c++ search" function
1)search string: "methodA*"
2)search for: Function
3)limitedto: references
But I got nothing !!


Finally, I download the source code of CDT from svn, write programs as below to
get callers of function with name "methodA", I still just got one function
reference from function "method42". The function "method41" is missing.

----------------------------------
void getCallers(ICProject project, IIndex index, IIndexBinding callee)
throws CoreException
{
IIndexName[] callers = index.findReferences(callee);
for (int i = 0; i < callers.length; i++) {
IIndexName rname = callers[i];
IIndexName caller = rname.getEnclosingDefinition();
if (caller != null) {
ICElement elem = IndexUI.getCElementForName(project, index,
caller);
if (elem != null) {
result.add(elem, rname);
}
}
}//for
}//getCallers()
----------------------------------

what happened? PDOM index may have some problem
Re: error of "Open declaration" [message #673909 is a reply to message #673741] Wed, 25 May 2011 07:01 Go to previous message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
If this bug is still alive in Eclipse 3.7 (CDT 8.0) then you should file a bugzilla request to fix it.

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:Problem with debugger
Next Topic:subdir.mk with relative paths? or makefiles from .cproject?
Goto Forum:
  


Current Time: Thu Apr 25 01:36:21 GMT 2024

Powered by FUDForum. Page generated in 0.03184 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top