Is there a way to run the GCC preprocessor, but only for user-defined macros?
I have a few one-liners and some #ifdef, etc. conditionals, and I want to see what my code looks like when just those are expanded.
As it is, the includes get expanded, my fprintf(stderr)s turn into fprintf(((__getreeent())->_stderr), etc.
Call
cppdirectly, e.g.Of course, if you include any headers then those will be included in the output. One way to avoid that might be to just
grep -vout the lines with#includes (or perhaps just ones with#include <and allow#include "). Or you could specify the-nostdincoption to remove just standard includes (but possibly leave in local libraries unless you specify include paths so that they won’t be found) – this would warn about missing headers, though.Edit: Or use the preprocessor itself to make the inclusion of headers conditional, wrap them in something like
#ifndef TESTING_PREPROCESSORand use-DTESTING_PREPROCESSOR.