C Source code pre-processing

Burn Alting burn at goldweb.com.au
Tue Mar 26 12:23:02 EST 2002

On Tue, 26 Mar 2002 11:47, Michael Still wrote:
> On Tue, 26 Mar 2002, Burn Alting wrote:
> > 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.
> Couldn't you just run cpp yourself?
> Mikal

I should have been clearer in my original post.

My problem is that I have a 'master source tree'. I use #defines and 
#if/#else/#elif/#endif constructs to define certain features. This is great 
for generating different binaries, but I also need to occassionally generate 
a source subset (from the master) which has deleted references to certain of 
these 'features' - this includes the deletion of the #if/#else/#elif/#endif 
lines as well.

cpp (-P, -C etc) or gcc's -E doesn't do this, both are more concerned with 
generating intermediate C code - eg macro expansion etc. A cursory glance at 
the m4 utility (earlier cpp) doesn't appear to help either.

I suppose this is more of an editing problem than anything else, I was just 
hopeing that someone may have done this before me (eg Mark Jarnyk's python 



More information about the linux mailing list