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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!deci.cs.umn.edu!hansen
  3. From: hansen@deci.cs.umn.edu (David M. Hansen)
  4. Subject: Re: Debugging output
  5. Message-ID: <1992Nov6.135017.6870@news2.cis.umn.edu>
  6. Sender: news@news2.cis.umn.edu (Usenet News Administration)
  7. Nntp-Posting-Host: deci.cs.umn.edu
  8. Organization: University of Minnesota
  9. References: <spuler.720931050@coral> <Bx9369.3zL@cs.uiuc.edu>
  10. Date: Fri, 6 Nov 1992 13:50:17 GMT
  11. Lines: 36
  12.  
  13. In article <Bx9369.3zL@cs.uiuc.edu>, pjl@cs.uiuc.edu (Paul Lucas) writes:
  14. |> *****>    This is overkill; the same thing can be achieved without
  15. |>     inventing another class:
  16. |> 
  17. |>     #ifdef DEBUG
  18. |>     #    define    CDEBUG    if ( debug ) cerr
  19. |>     #else
  20. |>     #    define    CDEBUG    //
  21. |>     #endif
  22. |> 
  23. |>     // ...
  24. |> 
  25. |>     CDEBUG << "here\n";
  26. |> 
  27. |>     This allows the flexibility of having debugging "togglable"
  28. |>     during development, presumeably by a command-line option, but
  29. |>     can be compiled-out in the final version.
  30. |> 
  31.  
  32. I think it is a mistake to rely on what is essentially a bug in many C++
  33. compilers.  According to the ARM (section 16.1, page 370)  "...a single white
  34. space replaces each comment..." _before_ preprocessing directives are 
  35. executed.  The annotation recognizes that C preprocessors, unless adapted
  36. for use with C++, will not recognize the // comment form, but it also makes
  37. it clear that is is inappropriate behavior.
  38.  
  39. It is a bug because it means you have to be _very_ careful about how you 
  40. comment your code.  For example,
  41.  
  42.    #define MAX_WIDGETS   12    // maximum number of widgets available to the user
  43.  
  44.    Widget user_widgets[MAX_WIDGETS];
  45.  
  46. will not parse appropriately, leading to non-sequiter error messages.
  47.  
  48.                     -=Dave
  49.