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

Bill Silvert silvert at cs.dal.ca
Fri May 4 22:26:48 AEST 1990


In the recent postings there were a number of solutions to the problem
of defining a function DEBUG which optionally works like printf.  Only
one addresses the fact that debugging information should preferably go
to stderr:

In article <8060 at goofy.Apple.COM> escher at Apple.COM (Michael Crawford) writes:
>more elegant still:
>
>#ifdef DEBUG
>#define fDebug( x ) fprintf x
>#define Debug( x ) printf x
>#else
>#define fDebug( x )
>#define Debug( x )
>#endif
>
>fDebug(( stderr, "debugging info" ));
>Debug(( "debugging info" ));

Is there a way to define Debug so that Debug(x, y, z,...) can optionally
either do nothing or generate fprintf(stderr, x, y, z,...) with an
arbitrary number of arguments?  Crawford's method still requires
specific mention of stderr in each debug line.

-- 
William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography
P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2.  Tel. (902)426-1577
UUCP=..!{uunet|watmath}!dalcs!biomel!bill
BITNET=bill%biomel%dalcs at dalac	InterNet=bill%biomel at cs.dal.ca



More information about the Comp.unix.wizards mailing list