home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!umn.edu!deci.cs.umn.edu!hansen
- From: hansen@deci.cs.umn.edu (David M. Hansen)
- Subject: Re: Debugging output
- Message-ID: <1992Nov6.135017.6870@news2.cis.umn.edu>
- Sender: news@news2.cis.umn.edu (Usenet News Administration)
- Nntp-Posting-Host: deci.cs.umn.edu
- Organization: University of Minnesota
- References: <spuler.720931050@coral> <Bx9369.3zL@cs.uiuc.edu>
- Date: Fri, 6 Nov 1992 13:50:17 GMT
- Lines: 36
-
- 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.
-
- -=Dave
-