C Source code pre-processing
Burn Alting
burn at goldweb.com.au
Tue Mar 26 10:26:01 EST 2002
Hi Peoples,
Does anyone know of a utility which will take a C source file and strip
#if/#else/#endif directives, just leaving the source code dependant upon a
set of defines.
For example, say I had
#if SOURCE_ALTERNATIVE_01
/*
* Source alternative 01
*/
#else /* SOURCE_ALTERNATIVE_01 */
/*
* Source
*/
#endif /* SOURCE_ALTERNATIVE_01 */
then the execution of the utility I'm looking for would generate
/*
* Source Alternative 01
*/
if I had defined SOURCE_ALTERNATIVE_01 to be 1, or
/*
* Source
*/
if I had defined SOURCE_ALTERNATIVE_01 to be 0.
The -E option to gcc is no use, nor it appears are the various options to cpp
(eg -P -C).
I suppose I could wip up something in lex/yacc but I'd rather check if
someone has already done this.
Thanks in advance
Burn Alting
burn at goldweb.com.au
More information about the linux
mailing list