|C/C++ header file parser firstname.lastname@example.org (Pankaj Garg) (2006-09-30)|
|Re: C/C++ header file parser email@example.com (2006-10-03)|
|Re: C/C++ header file parser firstname.lastname@example.org (Pascal Bourguignon) (2006-10-03)|
|Re: C/C++ header file parser email@example.com (Alex McDonald) (2006-10-03)|
|Re: C/C++ header file parser firstname.lastname@example.org (Paul Pluzhnikov) (2006-10-03)|
|Re: C/C++ header file parser email@example.com (Michael Tiomkin) (2006-10-03)|
|Re: C/C++ header file parser firstname.lastname@example.org (Ira Baxter) (2006-10-10)|
|From:||"Michael Tiomkin" <email@example.com>|
|Date:||3 Oct 2006 18:17:34 -0400|
|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.
Return to the
Search the comp.compilers archives again.