Writing a MACRO that expands to another MACRO will require the preprocessor to execute it twice.
This is not done.
You can write a simple file,
// File check-defines.c int printCompileTimeDefines() { #ifdef DEF1 printf ("defined : DEF1\n"); #else // DEF1 printf ("undefined: DEF1\n"); #endif // DEF1 // and so on... }
Use the same compile time options in this file as in other files.
Call the function sometime at the beginning.
If you have #DEFINE lines inside the source file, not a Makefile ,
Move them to another Header file and include this header in all source files,
including check-defines.c .
I hope you have the same set of definitions allowed in all of your source files.
Otherwise, it would be wise to reconsider the strategy of your definitions.
To automate the generation of this function ,
you can use the M4 macro (or even the AWK script actually).
M4 becomes your pre-processor.
nik
source share