Xref: utzoo comp.lang.c:28399 comp.unix.wizards:21773 alt.sources:1825 comp.sources.d:5250 misc.misc:9653 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!dogie.macc.wisc.edu!uwvax!umn-d-ub!cs.umn.edu!thornley From: thornley@cs.umn.edu (David H. Thornley) Newsgroups: comp.lang.c,comp.unix.wizards,alt.sources,comp.sources.d,misc.misc Subject: Re: #define DEBUG... (using printf for debugging) Message-ID: <1990May3.192347.12973@cs.umn.edu> Date: 3 May 90 19:23:47 GMT References: <11290@hoptoad.uucp> <40628@cornell.UUCP> Organization: University of Minnesota, Minneapolis - CSCI Dept. Lines: 24 In article <40628@cornell.UUCP> gordon@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 How about #ifdef DEBUG #define D(X) X #else #define D(X) #endif and D(printf("debugging information\n");) If DEBUG is defined, anything in D() is used as is; if not, anything in D() is disregarded. It seems to work for me. David Thornley