#define DEBUG... (using printf for debugging)

Ronnie Kon ronnie at mindcrf.UUCP
Fri May 4 08:04:46 AEST 1990


In article <40628 at cornell.UUCP> gordon at cs.cornell.edu (Jeffrey  Adam Gordon) writes:
>I want to have a DEBUG flag which controls whether diagnostic printfs
>are executed or not.
>		[ lots of stuff deleted ]

	How about:

#if WANT_DEBUGGING
#	define	DEBUG(a,b,c,d,e)	printf(a,b,c,d,e)
#else
#	define	DEBUG(a,b,c,d,e)
#endif

This is ugly, in that you must always supply a fixed number of parameters,
but it's quick and easy.  You can also use multiple definitions, DEBUG1,
DEBUG2, etc, each taking a different number of parameters.

	If your application is not real-time, you can also make DEBUG a real
routine, which does nothing if your definition is not turned on, and a printf
if it is.  This causes an overhead of a few microseconds on an average
machine (say a 10MHz 68000) each call.

	Hope this helps.

				Ronnie
-- 
-------------------------------------------------------------------------------
Ronnie B. Kon                    |  "The answers to life's problems aren't at
kon at mindcraft.com                |  the bottom of a bottle: they're on TV!"
...!{decwrl,ames}!mindcrf!ronnie |               -- Homer Simpson
-------------------------------------------------------------------------------



More information about the Alt.sources mailing list