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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!think.com!ames!decwrl!csus.edu!netcom.com!ort
  3. From: ort@netcom.com (David Oertel)
  4. Subject: Re: Debugging output
  5. Message-ID: <1992Nov10.191848.28946@netcom.com>
  6. Summary: re: debugging output
  7. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  8. References: <spuler.720931050@coral> <1992Nov9.112051.21350@netcom.com> <EB.92Nov10081925@ascent.ascent.com>
  9. Date: Tue, 10 Nov 1992 19:18:48 GMT
  10. Lines: 40
  11.  
  12.  
  13.  
  14.  
  15. > Someone please correct me if I'm wrong, but I thought the arguments to
  16. > an inline function still had to be evaluated, even if they aren't used
  17. > in the body.  So if you write
  18.  
  19. > void debug(ostream& expr) { 
  20. > #ifdef DEBUG
  21. >   if (debug_flag) expr << endl;
  22. > #endif
  23. > }
  24.  
  25. > debug(cout << "foo: " << foo);
  26.  
  27. > wouldn't the compiler still have to arrange to do the output anyway as
  28. > part of argument evaluation, even when DEBUG is not defined?  I
  29. > thought it's not supposed to matter to the result whether a function
  30. > is inline or not.
  31.  
  32. > Or maybe I misunderstood the suggestion?
  33.  
  34. Ed,
  35.     Your question is good, and I hope some compiler jock gives us the 
  36.     answer.  What I had in mind, however, was something like:
  37.  
  38.     void debug(ostream& out, String& desc, int val){
  39.     #ifdef DEBUG
  40.         out << desc << val;
  41.     #endif
  42.     }
  43.  
  44.     debug(cout, "foo: ", foo);
  45.  
  46.     I don't know whether either version generates code for DEBUG not 
  47.     defined.  Thinking naively about how macros are typically implemented,
  48.     I would suspect not.
  49.  
  50.     ort@netcom.com
  51. -- 
  52.