I do not know any such function in the gcc preprocessor. And depending on what you are trying to do, it may even be impossible. If the #ifdef directive refers to a macro previously defined (or not) by the #define directive, and you ignore the #define directives, then this obviously does not work.
But the unifdef command is likely to be what you are looking for. I just installed it on my Ubuntu system using sudo apt-get install unifdef ; There should be similar installation methods on other systems.
source share