gcc preprocessor: can I resolve #if[def]s only, leave other directives untouched?
c, c++, gcc
Solution
I don't know of any such functionality in gcc's preprocessor. And depending on what you're trying to do, it might not even be possible. If a `#ifdef` directive refers to a macro previously defined (or not) by a `#define` directive, and you ignore `#define` directives, then that's clearly not going to work.
But the unifdef command is likely to be what you're looking for. I just installed it on my Ubuntu system with `sudo apt-get install unifdef`; there should be similar ways to install it on other systems.
Problem
I'm doing some reverse engineering on some old code that is configured by a massive tangle of #ifs and #ifdefs. I'm currently looking at the various configurations by doing the substitutions in an editor. This is both tedious and (I suspect) error-prone. Are there some gcc preprocessor options that will preprocess the #if[def]s but leave other preprocessor directives (e.g. #define) untouched? This is for reverse engineering purposes only; I don't need to compile or otherwise use the preprocessed code.