Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Psepha

Debug functions

This topic is 6926 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Not much more I can say

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!