This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: #define in a macro definition


bill wrote:

> I was trying to do exactly this type of thing just last night!  My
> reason is I've got
> a bunch of code that reads:
> #ifdef FOO
> debug("FOO\n");
> #endif
> It's printing to a debug file to help track down what options were
> defined.  This is
> several hundred lines of code, and it's a bit ugly.  It would be nice to
> be able to
> write "PRINT_MACRO(FOO)"  and have it expand to the 3 lines above.

But why in the world would PRINT_MACRO need to include the #ifdef?  Why
not just do this once:

#ifdef FOO
#  define PRINT_MACRO(x) debug(x)
#else
#  define PRINT_MACRO(x)
#endif

Brian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]