home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1262 < prev    next >
Internet Message Format  |  1990-12-28  |  1KB

  1. From: CMH117@psuvm.psu.edu (Charles Hannum)
  2. Newsgroups: comp.lang.c,comp.unix.wizards,alt.sources,comp.sources.d,misc.misc
  3. Subject: Re: #define DEBUG... (using printf for debugging)
  4. Message-ID: <90123.152729CMH117@psuvm.psu.edu>
  5. Date: 3 May 90 19:27:29 GMT
  6.  
  7.  
  8. #ifdef DEBUG
  9. #define  debug(x)  printf x
  10. #else
  11. #define  debug(x)
  12. #endif
  13.  
  14.  
  15. Then, you can just use something like:
  16.  
  17.   debug(("%s\n","This is a test."));      (<===  This is an EXAMPLE; it's not
  18.                                                  meant to be efficient, just
  19.                                                  to emphasize the syntax!!!!)
  20.  
  21. in your code.  Just like printf(), except you need *two* parentheses around
  22. the argument list.
  23.  
  24. I've been using this trick for years.
  25.  
  26.  
  27. Virtually,
  28. - Charles Martin Hannum II         PennMUD Design Team - (Resident) Programmer
  29.     (That's Charles to you!)       "Those who say a thing cannot be done should
  30.   Please send mail to:              under no circumstances stand in the way of
  31.   hannum@haydn.psu.edu              he who is doing it." - a misquote
  32.