Xref: utzoo comp.lang.c:28546 comp.unix.wizards:21861 alt.sources:1850 comp.sources.d:5301 misc.misc:9692 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucsd!swrinde!dfsun1!fenske From: fenske@dfsun1.electro.swri.edu (Robert Fenske Jr) Newsgroups: comp.lang.c,comp.unix.wizards,alt.sources,comp.sources.d,misc.misc Subject: Re: #define DEBUG... (using printf for debugging) Message-ID: <1521@dfsun1.electro.swri.edu> Date: 8 May 90 13:11:17 GMT References: <11290@hoptoad.electro.swri.edu> <40628@cornell.electro.swri.edu> <801@oz.rci.dk> Reply-To: fenske@dfsun1.electro.swri.edu (Robert Fenske Jr) Followup-To: comp.lang.c Organization: Southwest Research Institute, San Antonio, Texas Lines: 24 In article <801@oz.rci.dk> kc@oz.rci.dk (Knud Christensen) writes: >gordon@mimir.cs.cornell.edu (Jeffrey Adam Gordon) writes: > >>I want to have a DEBUG flag which controls whether diagnostic printfs >>are executed or not. > How 'bout this: #define DPRINTF(s) if (DEBUG) printf(s) which can't be used in "if" statements for example--but still useful--or this: #define DPRINTF(s) (DEBUG ? printf(s) : 0) with perhaps some compilers complaining about a useless statement when debug is zero. DEBUG could be a #define or a variable and can be easily taken care of on the compiler command line. -- Robert Fenske, Jr. Sw | The Taming the C*sm*s series: Electromagnetics Division /R---\ | Southwest Research Institute | I | | "The Martian canals were the dfsun1.electro.swri.edu 129.162.160.4 \----/ | Martians' last ditch effort."