
13 Nov
2004
13 Nov
'04
10:27 a.m.
Eljay Love-Jensen wrote:
Hi Reece,
You'd have to run the source code through the pre-processor twice to remove the comments.
Comments are stripped out first, then macro-expansion. (Not surprisingly, Microsoft's compiler is non-compliant, and the trick works on their platform.)
How about: class null_log { public: template< typename T > null_log & operator<<( const T & ) { return *this; } }; null_log log; #define BOOST_LOG(id) log This should work and a good compiler should be able to optimize away the log output, leaving only the small footprint of the global variable. It also has the advantage of being multi-line compatible: BOOST_LOG(dbg) << "message: " << foobar; Regards, Reece