Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Macro for member function

Reply
Thread Tools

Macro for member function

 
 
yoonghm@gmail.com
Guest
Posts: n/a
 
      09-20-2006
Hi:

I have a large piece of C++ source code that make use of cout
function to perform run-time trace. Due to performance issues, I would
like to turn off the it from the compilation. However, I do not want to
change each of the source code but only the trace functions. For
example,

int
main()
{
TRACE::Show(xxxx)
...
}

In the trace.h:

Class TRACE
{

public: Show(xxxx);

}

In the trace.cc

TRACE::Show(xxx)
{

}

Any example to use macro to define the Show(xxx) to none from the
trace.cc or trace.h?

Regards
Yoong

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      09-20-2006
yoonghm wrote:

> I have a large piece of C++ source code that make use of cout
> function to perform run-time trace. Due to performance issues, I would
> like to turn off the it from the compilation. However, I do not want to
> change each of the source code but only the trace functions. For
> example,


> TRACE::Show(xxxx)


/The C++ Programming Language, 3rd Edition/, by Bjarne Stroustrup, has a
perfect example of this, with a template. Could someone whip it out, please?

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
 
 
 
Frederick Gotham
Guest
Posts: n/a
 
      09-20-2006

> I have a large piece of C++ source code that make use of cout
> function to perform run-time trace.



"cout" is a global object -- not a function.


> Due to performance issues, I would
> like to turn off the it from the compilation. However, I do not want to
> change each of the source code but only the trace functions. For
> example



Maybe something like the following:

class CoutManipulator {
public:
template<class T>
CoutManipulator &operator<<(T const&) {return *this;}

template<class T>
CoutManipulator const &operator<<(T const&) const {return *this;}
} coutmanipulator;

#define cout coutmanipulator

/* Code goes here */

#undef cout

--

Frederick Gotham
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to member function and pointer to constant member function Fraser Ross C++ 4 08-14-2004 06:00 PM
performance of static member function vs. instance member function 0to60 C++ 4 11-21-2003 05:25 PM
Function pointer member variable to non-member function Alex C++ 0 10-15-2003 05:26 PM
Function pointer member variable to non-member function slide_o_mix C++ 0 10-15-2003 03:37 PM
Passing a pointer to member function as a parameter to another member function Newsgroup - Ann C++ 5 07-30-2003 02:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57