Given the following C source code
#ifdef FOO
int bar = 1;
#endif
#if FOO == 0
int x = 0;
#elif FOO == 1
int x = 1;
#elif FOO == 2
int x = 2;
#endif
I can preprocess the source code (e.g. with unifdef / coan) as if FOO
was either undefined, defined at all or defined as a specific value (coan -DFOO=1 ...
would rewrite the code as int bar = 1; int x = 1;
).
However, for some variables I want to preprocess on (e.g. _MSC_VER
) I don't know the exact value, but I know which values I want to filter out.
Ideally, I could run coan -DFOO!=0
or coan -DFOO>0
to drop the parts that don't match but keep the #if
s that can't be evaluated yet.
Is there any preprocessor that can handle more advanced constraints like this?