home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ukma!darwin.sura.net!spool.mu.edu!umn.edu!The-Star.honeywell.com!saifr00.cfsat.honeywell.com!murali
- From: murali@saifr00.cfsat.honeywell.com (R. Muralidhar)
- Subject: Re: Debugging output
- In-Reply-To: pjl@cs.uiuc.edu's message of Thu, 5 Nov 1992 16:01:20 GMT
- Message-ID: <1992Nov5.185929.15279@saifr00.cfsat.honeywell.com>
- Organization: Honeywell Air Transport Systems Division
- References: <spuler.720931050@coral> <Bx9369.3zL@cs.uiuc.edu>
- Date: Thu, 5 Nov 92 18:59:29 GMT
- Lines: 55
-
-
- In <Bx9369.3zL@cs.uiuc.edu> 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
- >>operator << to produce debugging output in a way that it can be removed
- >>easily from production code. The obvious method is:
-
- >>#ifdef DEBUG
- >> cerr << .....
- >>#endif
-
- >>but I'd like to avoid the #ifdef -#endif lines.
-
- >*****> Why? In a "final" version, you don't want debugging code in the
- > object file.
-
- I, too, have felt a similar need like David Spuler. For one, those #ifdef -
- #endif lines interfere with neatly indented code, are unsightly, and make
- the code less readable. (I don't discount their usefulness, don't get me
- wrong.)
-
- >>I've been trying to declare my own "dbg" streams by inheriting it
- >>from the standard "ostream" class and redefining the << operators.
-
- > [stream that has flag whether to print elided]
-
- >*****> This is overkill; the same thing can be achieved without
- > inventing another class:
-
- > #ifdef DEBUG
- > # define CDEBUG if ( debug ) cerr
- > #else
- > # define CDEBUG //
- > #endif
-
- > CDEBUG << "here\n";
-
- This method will work only if all the information to be 'output' appears in
- one source line. What if I had to do (for readability purposes):
-
- CDEBUG << "here is senetence one.\n"
- << "here is sentence two.\n";
-
- The technique Paul Lucas suggests wouldn't work, but David's would.
-
- Muralidhar Rajappa murali@saifr00@cfsat.honeywell.com
- Honeywell Commercial Flight Systems Group
- Phoenix, AZ
- --
- _
- /|/), , ;_ _ // .
- (/ /(_<_/ '(_(_X_<_
- murali@saifr00.cfsat.honeywell.com
-