Related articles |
---|
C/C++ header file parser lost_stranger@verizon.net (Pankaj Garg) (2006-09-30) |
Re: C/C++ header file parser daw@taverner.cs.berkeley.edu (2006-10-03) |
Re: C/C++ header file parser pjb@informatimago.com (Pascal Bourguignon) (2006-10-03) |
Re: C/C++ header file parser alex_mcd@btopenworld.com (Alex McDonald) (2006-10-03) |
Re: C/C++ header file parser ppluzhnikov-nsp@charter.net (Paul Pluzhnikov) (2006-10-03) |
Re: C/C++ header file parser tmk@netvision.net.il (Michael Tiomkin) (2006-10-03) |
Re: C/C++ header file parser idbaxter@semdesigns.com (Ira Baxter) (2006-10-10) |
From: | "Michael Tiomkin" <tmk@netvision.net.il> |
Newsgroups: | comp.compilers |
Date: | 3 Oct 2006 18:17:34 -0400 |
Organization: | Compilers Central |
References: | 06-09-169 |
Keywords: | C++, parse |
Posted-Date: | 03 Oct 2006 18:17:34 EDT |
Pankaj Garg wrote:
> I need to parse C/C++ header files and extract information about data
> types, functions and function arguments. Which tools/libraries would
> be suitable for me? Are there any examples/sample programs for such.
>
> I don't want to build a full fledged yacc based parser so i am looking
> for a ready made parser, preferably open source.
All the compilers use the type info in order to create the debug
info part of the compiled object. Unfortunately, if the type is not
used, they ignore it. You can take gcc and force it to save the type
info of unused types. Then you can compile any header file and read
its debug info. The only problem would be the C++ templates, because
they usually are not a part of debug info. You can save the precompied
templates somewhere and read them later. Recall that you should run
the compiler with the same options that you use in the project,
because this influences the macro language, struct alignment etc.
A "dirtier" solution can be changing ctags to include the
declarations instead of definitions. ctags has a much simpler parser,
however I'm not sure if the modern ctags can parse C++ files.
Michael
Return to the
comp.compilers page.
Search the
comp.compilers archives again.