How to get function declaration source file/line from definition?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings. In my C or C++ source file I have a separate function declaration
and definition. For example:

// example.c
static void Something();
static void Something() {}

// example.cpp
namespace {
void Something();
void Something() {}
}

When iterating the AST in these cases I only find one 'FUNCTION_DECL' tree
node for 'Something' where 'DECL_SOURCE_LINE' returns the definition
location. I would like to also get the location of the declaration. The
header information for 'DECL_SOURCE_LINE' in 'tree.h' states, "If the
declaration appears in several places (as for a C function that is declared
first and then defined later), this information should refer to the
definition." But what I do not understand if it is therefore impossible to
get the source line of the declaration altogether. Is there another tree
node accessible pertaining to the declaration? Is there some other means? I
searched the archive and did not find an answer to my situation. Any help is
appreciated.



--
View this message in context: http://gcc.1065356.n5.nabble.com/How-to-get-function-declaration-source-file-line-from-definition-tp1228358.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux