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