#69380 - sgeos - Mon Jan 30, 2006 12:54 pm
Does anyone know and easy way to:
A) remove all comments from a source file
B) expand all macros (mainly interesed in #include)
C) toss the results into another file (easy enough)
NOTE: The files will not necessarily be C source files, although the commenting system and the preprocessor will necessarily be the same.
I'm looking to turn this:
[happy.c]
Into this:
[happy.c.out]
Or this:
[happy.c.out]
Depending on how HAPPY_DEBUG is defined.
Well, I'm off to the docs. I vaguely remember reading about a gcc command line option that does all this happy magic. =P
-Brendan
A) remove all comments from a source file
B) expand all macros (mainly interesed in #include)
C) toss the results into another file (easy enough)
NOTE: The files will not necessarily be C source files, although the commenting system and the preprocessor will necessarily be the same.
I'm looking to turn this:
[happy.c]
Code: |
/*** happy.c
* * This is a happy module. * It makes your sad modules happy! */ #include "happy.h" // This function is happy void happy(void) { do_print ( "happy" #if HAPPY_DEBUG " debug /* Happy Happy */" #endif // HAPPY_DEBUG "// Really Happy!\n" ); /* FIXME: Cleanup this mess. */ // do_happy_dance(BIG_HAPPY); // do_happy_dance(BIG_HAPPY | NOT_SAD); do_happy_dance(HAPPY_DEBUG); } |
Into this:
[happy.c.out]
Code: |
(whatever happy.h brings in)
void happy(void) { do_print ( "happy" "// Really Happy!\n" ); do_happy_dance(0); } |
Or this:
[happy.c.out]
Code: |
(whatever happy.h brings in)
void happy(void) { do_print ( "happy" " debug /* Happy Happy */" "// Really Happy!\n" ); do_happy_dance(1); } |
Depending on how HAPPY_DEBUG is defined.
Well, I'm off to the docs. I vaguely remember reading about a gcc command line option that does all this happy magic. =P
-Brendan