home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15901 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.6 KB  |  48 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!sdd.hp.com!wupost!gumby!yale!yale.edu!ira.uka.de!ira.uka.de!gmd.de!Germany.EU.net!mcsun!sunic!hagbard!loglule!jbn
  2. From: jbn@lulea.trab.se (Johan Bengtsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Debugging output
  5. Message-ID: <5174@holden.lulea.trab.se>
  6. Date: 6 Nov 92 18:05:07 GMT
  7. References: <Bx93Mr.42r@cs.uiuc.edu>
  8. Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
  9. Lines: 36
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. pjl@cs.uiuc.edu (Paul Lucas) writes:
  13. : >In <spuler.720931050@coral> spuler@coral.cs.jcu.edu.au (David Spuler) writes:
  14. : >>I was wondering whether anyone has any suggestions as to how to use the neat
  15. : >    #ifdef DEBUG
  16. : >    #    define    CDEBUG    if ( debug ) cerr
  17. : >    #else
  18. : >    #    define    CDEBUG    //
  19. : >    #endif
  20. [...]
  21. : >    CDEBUG << "here\n";
  22. : >    This allows the flexibility of having debugging "togglable"
  23. : >    during development, presumeably by a command-line option, but
  24. : >    can be compiled-out in the final version.
  25.  
  26. I much prefer saying
  27.  
  28. DEBUG( cerr << "here\n" );
  29.  
  30. Much easier to see what is going on (IMHO), and useful for other things
  31. than printouts.
  32.  
  33. #ifndef NDEBUG
  34. #  define DEBUG(expr) if ( debug ) (expr)
  35. #else
  36. #  define DEBUG(expr) (0)
  37. #endif
  38.  
  39. Note that DEBUG code is generated per default.  Reversing that is trivial.
  40.  
  41. -- 
  42. --------------------------------------------------------------------------
  43. | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
  44. | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
  45. --------------------------------------------------------------------------
  46.