home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!pmafire!news.dell.com!swrinde!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!pjl
- From: pjl@cs.uiuc.edu (Paul Lucas)
- Subject: Re: Debugging output
- Message-ID: <BxAz2L.n4M@cs.uiuc.edu>
- Sender: news@cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- References: <spuler.720931050@coral> <Bx9369.3zL@cs.uiuc.edu> <1992Nov6.135017.6870@news2.cis.umn.edu>
- Distribution: usa
- Date: Fri, 6 Nov 1992 16:27:57 GMT
- Lines: 45
-
- In <1992Nov6.135017.6870@news2.cis.umn.edu> hansen@deci.cs.umn.edu (David M. Hansen) writes:
-
- >In article <Bx9369.3zL@cs.uiuc.edu>, pjl@cs.uiuc.edu (Paul Lucas) writes:
- >|> *****> 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 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 think it is a mistake to rely on what is essentially a bug in many C++
- >compilers. According to the ARM (section 16.1, page 370) "...a single white
- >space replaces each comment..." _before_ preprocessing directives are
- >executed. The annotation recognizes that C preprocessors, unless adapted
- >for use with C++, will not recognize the // comment form, but it also makes
- >it clear that is is inappropriate behavior.
-
- >It is a bug because it means you have to be _very_ careful about how you
- >comment your code. For example,
-
- > #define MAX_WIDGETS 12 // maximum number of widgets available to the user
-
- > Widget user_widgets[MAX_WIDGETS];
-
- >will not parse appropriately, leading to non-sequiter error messages.
-
- *****> I already pointed out that this only works on C++-ignorant
- preprocessors; the above example is a well-known pitfall and I
- consider it irrelevant. You always have to do everything
- carefully.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-