Christian Herget
Christian Herget

Reputation: 11

Partial preprocessing of C files

I'm searching for a preprocessor which allows for partial preprocessing of C source files. What I want to do is to skip certain or all #include and to define some macros on the command line (or a separate file), the preprocessor then should only process what I specified and ignore the rest.

Here is an example of what I want to do:

#define FOO  
#ifdef FOO  
/* FOO */  
#endif  
#ifdef BAR  
/* BAR */  
#endif  

should be translated into

/* FOO */  
#ifdef BAR  
/* BAR */  
#endif

Some time ago at my previous job I needed a similar preprocessor and I think that I found a link to a standalone preprocessor here on stackoverflow, however after an hour of searching the web I gave up.

Upvotes: 0

Views: 775

Answers (1)

rici
rici

Reputation: 241701

You might be looking for coan, which has the ability to interpret #if and #ifdef directives given a set of definition (or undefinitions) supplied on the command-line.

Upvotes: 2

Related Questions