home *** CD-ROM | disk | FTP | other *** search
- 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
-
- 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."
-