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

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Debugging output
  5. Message-ID: <BxAz2L.n4M@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <spuler.720931050@coral> <Bx9369.3zL@cs.uiuc.edu> <1992Nov6.135017.6870@news2.cis.umn.edu>
  9. Distribution: usa
  10. Date: Fri, 6 Nov 1992 16:27:57 GMT
  11. Lines: 45
  12.  
  13. In <1992Nov6.135017.6870@news2.cis.umn.edu> hansen@deci.cs.umn.edu (David M. Hansen) writes:
  14.  
  15. >In article <Bx9369.3zL@cs.uiuc.edu>, pjl@cs.uiuc.edu (Paul Lucas) writes:
  16. >|> *****>    This is overkill; the same thing can be achieved without
  17. >|>     inventing another class:
  18. >|> 
  19. >|>     #ifdef DEBUG
  20. >|>     #    define    CDEBUG    if ( debug ) cerr
  21. >|>     #else
  22. >|>     #    define    CDEBUG    //
  23. >|>     #endif
  24. >|> 
  25. >|>     // ...
  26. >|> 
  27. >|>     CDEBUG << "here\n";
  28. >|> 
  29. >|>     This allows the flexibility of having debugging "togglable"
  30. >|>     during development, presumeably by a command-line option, but
  31. >|>     can be compiled-out in the final version.
  32. >|> 
  33.  
  34. >I think it is a mistake to rely on what is essentially a bug in many C++
  35. >compilers.  According to the ARM (section 16.1, page 370)  "...a single white
  36. >space replaces each comment..." _before_ preprocessing directives are 
  37. >executed.  The annotation recognizes that C preprocessors, unless adapted
  38. >for use with C++, will not recognize the // comment form, but it also makes
  39. >it clear that is is inappropriate behavior.
  40.  
  41. >It is a bug because it means you have to be _very_ careful about how you 
  42. >comment your code.  For example,
  43.  
  44. >   #define MAX_WIDGETS   12    // maximum number of widgets available to the user
  45.  
  46. >   Widget user_widgets[MAX_WIDGETS];
  47.  
  48. >will not parse appropriately, leading to non-sequiter error messages.
  49.  
  50. *****>    I already pointed out that this only works on C++-ignorant
  51.     preprocessors; the above example is a well-known pitfall and I
  52.     consider it irrelevant.  You always have to do everything
  53.     carefully.
  54. -- 
  55.     - Paul J. Lucas                University of Illinois    
  56.       AT&T Bell Laboratories        at Urbana-Champaign
  57.       Naperville, IL            pjl@cs.uiuc.edu
  58.