[comp.sources.d] #defineing debug

rich@eddie.mit.edu (Richard Caloggero) (05/09/90)

/* How about the following... */
/* Please mail to "rich@eddie.mit.edu" if there is a reason why this isn't a good technique!!! */
/* If you want debuging info to go to stderr, this won't work. */

#ifdef DEBUG_SWITCH
#define debug printf
#else
#define debug
#endif

main()
{
int stuff = 777;
debug ("stuff = %d", stuff);
}

-- 
						-- Rich (Richard Caloggero)	 (rich@eddie.mit.edu).
	The circle is open, but unbroken.
	Merry meet, merry part,
	and merry meet again.

ksb@nostromo.cc.purdue.edu (Kevin Braunsdorf) (05/09/90)

/* Pick just one: */

#define DEBUG	printf			/* always output debug stuff	*/

#define DEBUG	if (debug) printf	/* when run time switched	*/

#define DEBUG	if (0) (void)		/* when not debugging		*/


DEBUG("Answer the question asked, please\n");
DEBUG("Avoid side effects in debug code at all costs!\n");

--
"Going deeper than most - getting harder to touch?"
Kevin Braunsdorf, ksb@cc.purdue.edu, pur-ee!ksb, purdue!ksb