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

Robert Fenske Jr fenske at dfsun1.electro.swri.edu
Tue May 8 23:11:17 AEST 1990


In article <801 at oz.rci.dk> kc at oz.rci.dk (Knud Christensen) writes:
>gordon at 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."



More information about the Alt.sources mailing list