Original Post
hi, my debugging of code is slowly turning into a nightmare, my method this time around is to use windows MessageBox(); function for every message I need displayed, this has advantages - mainly it stops the execution of the program so you know where something has gone wrong, but when you are debugging a lot of data it can be quite boring having to click OK 1000+ times. I'm looking for a way I can pass a certain output handler to a module of code for it to use for debugging, so that in certain parts of code all I need to call is one function for outputting text. but I don't wan't the overhead of all these function calls in release mode, I've though of a couple of ways: C++ interface:
class IOutputHandler
{
public:
virtual void printf(const char*, ...) = 0;
};
and just pass an instance of this to a function, class etc. for it to use for displaying text, but it still has the function call overhead and a check to see if the pointer is null. templates:
class std_debug
{
public:
void printf(const char* format, ...)
{
...
}
} _std_debug;
template <class T>
void function(T debug)
{
debug.printf("", ...);
}
function(_std_debug);
still has the function call overhead (unless you create a class whos printf() does nothing then the compiler may? optimize the function call away). is there any better way of doing this?