I have a C file with some #include directives as well as #if, #ifdef, etc. I do NOT want #include directives to be expanded with the contents of the included files. I want #if directives and friends to be processed normally. How to do that with GCC?
I first tried -fdirectives-only option, but it processes both #include and #if directives.
Say I have a C file like this
#include <stdio.h>
#if FOO
int foo() {}
#else
int bar() {}
#endif
I want to get a preprocessed file
#include <stdio.h>
int foo() {}
or
#include <stdio.h>
int bar() {}
depending on you give -DFOO=1 or -DFOO=0.
However, with
gcc -E -DFOO=1 -fdirectives-only a.c
(or with any command line I tried, for that matter), I always get #include <stdio.h>
part expanded into > 1000 lines.
Note that my goal here is to generate multiple source files from a single file for humans to read, for which completely expanding #include and macros is NOT what I want.