Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Function declaration and definition in the same source file have different bindings


Hi

Suppose I have the following text in a file called foo.c

//---<beginning of file foo.c>

#include <stdio.h>

void foo(); //declaration

void foo() { //definition
  ...
}

int bar() {
  foo();
}

//---<end of file foo.c>

The declaration of foo has a declarator which has an IASTName; The IASTName
has an IBinding which can be retrieved by calling resolveBinding() on it.
Say this is binding1.

The function-definition also has a declarator, an IASTName and an IBinding
as above. Let us call this as binding2.

These two bindings binding1 and binding2 are different! I think this is a
bug because both the declaration and the definition belong to the same
semantic element which is function foo().

The call to foo() in bar() gets linked to the declaration instead of the
function-definition. I tried to build my index by keeping a map from
function-bindings to function-definitions. But since the bindings are
different between the function-definition and function-call are different I
am not able to resolve the call() to the definition. 

Please help. I want to build the index once for the entire project in the
first pass and use it to resolve function-calls in the second pass.

Thanks,
mani

-- 
View this message in context: http://www.nabble.com/Function-declaration-and-definition-in-the-same-source-file-have-different-bindings-tp23704926p23704926.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.



Back to the top