Complete macro expansion with cpp

peter.mathes@gmx.de
12 Feb 2005 17:48:44 -0500

          From comp.compilers

Related articles
Complete macro expansion with cpp peter.mathes@gmx.de (2005-02-12)
Re: Complete macro expansion with cpp RLake@oxfam.org.uk (Rici Lake) (2005-02-13)
Re: Complete macro expansion with cpp skandgoe@gwdg.de (Skandinavisches Seminar) (2005-02-13)
Re: Complete macro expansion with cpp codeworker@free.fr (2005-02-16)
Re: Complete macro expansion with cpp codeworker@free.fr (2005-02-16)
Re: Complete macro expansion with cpp peter.mathes@gmx.de (peter.mathes@gmx.de) (2005-02-16)
| List of all articles for this month |

From: peter.mathes@gmx.de
Newsgroups: comp.compilers
Date: 12 Feb 2005 17:48:44 -0500
Organization: http://groups.google.com
Keywords: C, question, comment

Hallo!
I need to get all macro #definitions output to stdout or some file.
The problem is:
When I pre-process the following lines


#define MACRO1 (1)
#define MACRO2 (MACRO1)


using cpp with the option '-dM' it outputs the same lines:


#define MACRO1 (1)
#define MACRO2 (MACRO1)


But I need an output with the macros expanded completely. Something
like this:


#define MACRO1 (1)
#define MACRO2 ((1))


Any idea how to get this done?


Thanks in advance
Peter
[If there's no existing tool, I'd think it'd be pretty easy to write a
grosse hacque in perl or python that runs cpp -dM, then took that
output and made a list of all the macros, ran that list through cpp to
get the expansions, then spliced the expansions back into #defines
-John]


Post a followup to this message

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