Not much more I can say
Debug functions
#define _DEBUG_ 1 // 0 to turn it off
and use #if because if you mistype _DEBUG_ the compiler will complain.
I often setup a scheme where I have multiple levels of debug, and I like being able to do
#if (DEBUG_LEVEL > 0)
...
#endif
for code that should always report debug information when debugging,
or
#if (DEBUG_LEVEL > 5)
..
#endif
for code that should only display debug information if I have set: #define DEBUG_LEVEL 6. This lets me cascade the error reporting. Sort of like you always want to report frame per second readouts, but not always whether your flip succeeded or not. Also think about using macros as reporting tools that are defined as doing nothing when not in debug mode, but do something else when debugging. This might be cleaner:
if (condition == FALSE)
{
DEBUG_REPORT("message");
return FALSE;
}
and the macro changes DEBUG_REPORT to doing nothing if DEBUG_LEVEL == 0.
I don't know I don't use that myself, but I have seen it used elsewhere.
For example I have a Network.dll err, well, dll really. If I want to create a debug version of this class (for that is what it is before compilation) is it an OK thing to code eg
Network::Network( char Param1,
#ifdef _DEBUG_
Debugger* DebugModuleClass,
#endif
char Param2 )
{
}
and then stick the #ifdef statement round bits of code that call the debugger? I know the whole kit and kaboodle will require a total recompilation to insert/remove the debug code but it seems to fit the bill. Any glaringly obvious mistakes/"You can't seriously do that!" comments?
Ta
Psepah