home *** CD-ROM | disk | FTP | other *** search
- 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
- From: jbn@lulea.trab.se (Johan Bengtsson)
- Newsgroups: comp.lang.c++
- Subject: Re: Debugging output
- Message-ID: <5174@holden.lulea.trab.se>
- Date: 6 Nov 92 18:05:07 GMT
- References: <Bx93Mr.42r@cs.uiuc.edu>
- Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
- Lines: 36
- X-Newsreader: Tin 1.1 PL4
-
- pjl@cs.uiuc.edu (Paul Lucas) writes:
- :
- : >In <spuler.720931050@coral> spuler@coral.cs.jcu.edu.au (David Spuler) writes:
- : >>I was wondering whether anyone has any suggestions as to how to use the neat
- : > #ifdef DEBUG
- : > # define CDEBUG if ( debug ) cerr
- : > #else
- : > # define CDEBUG //
- : > #endif
- [...]
- : > CDEBUG << "here\n";
- :
- : > This allows the flexibility of having debugging "togglable"
- : > during development, presumeably by a command-line option, but
- : > can be compiled-out in the final version.
-
- I much prefer saying
-
- DEBUG( cerr << "here\n" );
-
- Much easier to see what is going on (IMHO), and useful for other things
- than printouts.
-
- #ifndef NDEBUG
- # define DEBUG(expr) if ( debug ) (expr)
- #else
- # define DEBUG(expr) (0)
- #endif
-
- Note that DEBUG code is generated per default. Reversing that is trivial.
-
- --
- --------------------------------------------------------------------------
- | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden |
- | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490 |
- --------------------------------------------------------------------------
-