Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug-only ostreams in C++?

Tags:

People also ask

How to use printf for debugging?

printf() debugging It is easy to add printf() statements to your code to print out messages. In general, if you add printf() calls, you should print as much information as possible. For example, the meaning of the output "here" quickly gets lost. The ouput "DEBUG: i=27; count=35" conveys much more.

How do I enable macro debugging?

Then, when you want to turn on debug printing, just edit the first #define in the header file to say, e.g. If you need info from a frequently executed piece of code (i.e. a high level of detail), you may want to write: DEBUGLOG_LOG(3, "the value is: %d", anint);


I've implemented an ostream for debug output which sends ends up sending the debug info to OutputDebugString. A typical use of it looks like this (where debug is an ostream object):

debug << "some error\n";

For release builds, what's the least painful and most performant way to not output these debug statements?