#define DEBUG... (using printf for debugging)
    Karl Fox 
    karl at MorningStar.Com
       
    Fri May  4 06:02:16 AEST 1990
    
    
  
In article <40628 at cornell.UUCP> gordon at mimir.cs.cornell.edu (Jeffrey  Adam Gordon) writes:
   I want to have a DEBUG flag which controls whether diagnostic printfs
   are executed or not.
   The obvious way to do this is:
   #ifdef DEBUG
	   printf ("debugging information");
   #endif DEBUG
   But its a pain to have to type the #ifdef ... #endif all the time, and
   its less readable than simply having:
	   DEBUG ("debugging information");
   Now, I can use the latter format if I
   #define DEBUG printf
   but then how do I turn DEBUG off?
Here is a not-too-gross method I have seen suggested (and used):
    # define DEBUG(a) printf a
or, to disable it,
    # define DEBUG(a)
Then, call it with a double set of outer parentheses:
    DEBUG(("Warning: user %s has an ugly face!\n", user_name));
It even works as the THEN clause of an IF statement.
--
Karl Fox, Morning Star Technologies               karl at MorningStar.COM
    
    
More information about the Alt.sources
mailing list