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

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

 



Hi Manuel. Thank you for the response. Perhaps your answer is the definitive:


Manuel López-Ibáñez wrote
> My understanding is that once the definition is parsed, it overrides the
> old 
> declaration (they get merged).

I'm still missing something though:


> But of course the old declaration exists at least until this point:
> 
> test.c:3:22: error: new declaration ‘int Something()’
>   static int Something() { }
>                        ^
> test.c:2:13: error: ambiguates old declaration ‘void Something()’
>   static void Something();
>               ^
> Just set a breakpoint there and you'll see. Whether it remains accessible
> or
> not, I don't know. It all depends what you are trying to do. 

My understanding is with a gcc plugin, by the time I get to analyze the AST
the entire source file has been parsed. Therefore, I don't understand how I
could access the old declaration before the merge (maybe that was your final
answer). Also, the example you show has a different signature between
declaration and definition where the former returns 'void' and the latter
returns 'int'. Or when you say 'set a breakpoint', are you using the
different return value to effectively accomplish this? Sorry if you are
speaking high level and I'm not keeping up- please bear with me :)

I should modify my original question just slightly. It's not that I
necessarily need the declaration line number somehow from the definition.
Rather, I would like to get the declaration line number when the current
translation unit contains both.

Further guidance is appreciated. Thanks again.



--
View this message in context: http://gcc.1065356.n5.nabble.com/How-to-get-function-declaration-source-file-line-from-definition-tp1228358p1228386.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