Jump to content

  • Log In with Google      Sign In   
  • Create Account

Debug functions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Psepha   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 October 1999 - 08:26 PM

Just a general coding practice question is all......
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


Sponsor:

#2 MikeD   Members   -  Reputation: 158

Like
Likes
Like

Posted 06 October 1999 - 01:11 AM

That's pretty much the coding standard where I work and it works pretty well.

Not much more I can say


#3 Void   Members   -  Reputation: 126

Like
Likes
Like

Posted 06 October 1999 - 04:44 AM

I recommend using #if over #ifdef so you should

#define _DEBUG_ 1 // 0 to turn it off

and use #if because if you mistype _DEBUG_ the compiler will complain.


#4 Sphet   Members   -  Reputation: 631

Like
Likes
Like

Posted 06 October 1999 - 09:26 AM

I agree with Void about using #if instead of #ifdef

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.


#5 Psepha   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 October 1999 - 08:26 PM

Thanks for the feedback people. Looks like I am in the right area anyway.

Psepha





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS