home *** CD-ROM | disk | FTP | other *** search
- From: davidsen@sixhub.UUCP (Wm E. Davidsen 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: <908@sixhub.UUCP>
- Date: 4 May 90 00:38:46 GMT
-
- 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.
-
- #ifdef DEBUG
- #undef DEBUG /* prevent warning from redef */
- #define DEBUG(x) printf x
- #else
- #define DEBUG(x)
- #endif
-
- To use:
-
- DEBUG(("Any # of args: %d\n", whatever));
-
- The secret is in having the 2nd level of parens in the invocation of
- DEBUG and no parens in the expansion. Works like a charm!
- --
- bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
- sysop *IX BBS and Public Access UNIX
- moderator of comp.binaries.ibm.pc and 80386 mailing list
- "Stupidity, like virtue, is its own reward" -me
-