Re: Declaration, Definition & Reference listers for C

nmm1@cus.cam.ac.uk (Nick Maclaren)
24 Aug 2005 18:17:03 -0400

          From comp.compilers

Related articles
Declaration, Definition & Reference listers for C john.carter@tait.co.nz (John Carter) (2005-08-21)
Re: Declaration, Definition & Reference listers for C basile-news@starynkevitch.net (Basile Starynkevitch \[news\]) (2005-08-24)
Re: Declaration, Definition & Reference listers for C codeworker@free.fr (=?iso-8859-1?q?C=E9dric_LEMAIRE?=) (2005-08-24)
Re: Declaration, Definition & Reference listers for C nmm1@cus.cam.ac.uk (2005-08-24)
Re: Declaration, Definition & Reference listers for C Markus.Elfring@web.de (2005-08-24)
Re: Declaration, Definition & Reference listers for C DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2005-08-24)
Re: Declaration, Definition & Reference listers for C darius@raincode.com (Darius Blasband) (2005-08-24)
Re: Declaration, Definition & Reference listers for C aycock@cse.cpsc.ucalgary.ca (John Aycock) (2005-08-24)
Re: Declaration, Definition & Reference listers for C nicola.musatti@gmail.com (Nicola Musatti) (2005-08-24)
| List of all articles for this month |

From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.compilers
Date: 24 Aug 2005 18:17:03 -0400
Organization: University of Cambridge, England
References: 05-08-075
Keywords: tools, analysis

John Carter <john.carter@tait.co.nz> wrote:
>I'm interested in the large scale structure of very large programs (1000's
>of files)
>
>So to experiment with this I need to extract every {typedef, struct,
>union, enum, macro, variable and function} {declaration, definition and
>reference} from 1000's of C files.
>
>Anybody know of a tool to parse standard C and spit out this information?
>
>I would write one myself, but to do it properly I would have to write
>a C preprocessor and most of C compiler.


Yes. I have done that for Fortran and could take enough short-cuts to
make it fairly simple, but your description of what is needed for C is
correct.


The tradition answer is cxref, but that has rarely been upgraded to
ISO C, let alone extensions, and was/is often a bit iffy when the
program contains macros that create symbols. Hacking gcc is the other
sensible approach. Linux has cxref, but I can't tell you what it is
like, and whether it is a hacked gcc.


But you will have to decide exactly what you mean, anyway. If there
is a macro that creates symbols using external (e.g. -D) macros as
arguments, you need to know all input macros to parse the program.
And, in other cases, certain combinations of external macros will lead
to code that isn't even remotely C.




Regards,
Nick Maclaren.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.