home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!ames!decwrl!csus.edu!netcom.com!ort
- From: ort@netcom.com (David Oertel)
- Subject: Re: Debugging output
- Message-ID: <1992Nov10.191848.28946@netcom.com>
- Summary: re: debugging output
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- References: <spuler.720931050@coral> <1992Nov9.112051.21350@netcom.com> <EB.92Nov10081925@ascent.ascent.com>
- Date: Tue, 10 Nov 1992 19:18:48 GMT
- Lines: 40
-
-
-
-
- > Someone please correct me if I'm wrong, but I thought the arguments to
- > an inline function still had to be evaluated, even if they aren't used
- > in the body. So if you write
-
- > void debug(ostream& expr) {
- > #ifdef DEBUG
- > if (debug_flag) expr << endl;
- > #endif
- > }
-
- > debug(cout << "foo: " << foo);
-
- > wouldn't the compiler still have to arrange to do the output anyway as
- > part of argument evaluation, even when DEBUG is not defined? I
- > thought it's not supposed to matter to the result whether a function
- > is inline or not.
-
- > Or maybe I misunderstood the suggestion?
-
- Ed,
- Your question is good, and I hope some compiler jock gives us the
- answer. What I had in mind, however, was something like:
-
- void debug(ostream& out, String& desc, int val){
- #ifdef DEBUG
- out << desc << val;
- #endif
- }
-
- debug(cout, "foo: ", foo);
-
- I don't know whether either version generates code for DEBUG not
- defined. Thinking naively about how macros are typically implemented,
- I would suspect not.
-
- ort@netcom.com
- --
-