This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Function declared extern "C" does not appear in getdecls() list


Hello,

I noticed that a function that is declared as extern "C" in an include file does not appear in the getdecls() list for the top level.

Example:
-----------------------------------------
// file: test.cc

// next line may be included by an #include directive
extern "C" int test_function();

int test_function1(){};
int test_function() {};
int test_function2(){};
-----------------------------------------


I am using this code to dump the declarations list: (called just after compile_file() in toplev.c from the gcc-2.95-3)


{
tree decl;

for (decl = getdecls(); decl != NULL_TREE; decl = TREE_CHAIN(decl)) {
printf("DUMP: %s(%d): ",
tree_code_name[TREE_CODE (decl)],
TREE_CODE (decl));

/* test if declaration has a name to print */
if ((DECL_NAME(decl) > 0) && (IDENTIFIER_POINTER(DECL_NAME(decl)) > 0)) {
printf("%s (%s), in %s.\n",
IDENTIFIER_POINTER(DECL_NAME(decl)),
tree_code_name[TREE_CODE(TREE_TYPE(decl))],
DECL_SOURCE_FILE(decl));
} else {
printf("!NONAME!, in %s.\n",
DECL_SOURCE_FILE(decl));
}
} // for
}



The output is just:

DUMP: function_decl(29): test_function2 (function_type), in test.cc.
DUMP: function_decl(29): test_function1 (function_type), in test.cc.
... (other declarations are from <internal>) ...


The function test_function() does not appear!

As this function is getting compiled anyway (in an larger exemple), I think there is another way to find it's FUNCTION-DECL node. Can someone help me to find it? I need it because I'm tying to extract the hierarchy from a C++ source (including variables).



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]