Jump to content
  • Advertisement
Sign in to follow this  
nimnimnim

pretty way to throw/assertfail/etc with message.. or have VS spell out thrown text?

This topic is 3783 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

m$'s implementation of the stl classes makes use of some _Debug_message function (through _DEBUG_ERROR macro declared in xutility) which makes the errors assert-failed or thrown (?) from those classes spelled out at the first prompt. I'd like to keep my code iso c++ though etc.. when I'm not really sure which of two adjacent lines with throw statements produced the throw I may think an assert(<failing condition> && "message"); would make life easier.. but it's not very pretty. what's your way to do this to have it both standard and handy? I was going to give up pretentions and just tentatively define a MY_DEBUG_ERROR _DEBUG_ERROR of m$' but then I couldn't get it to resolve _Debug_message so gave up for today.. [Edited by - nimnimnim on May 12, 2008 4:57:15 PM]

Share this post


Link to post
Share on other sites
Advertisement
Here are some debug macros I wrote a while back, you may find them useful:


/* Variadic macros are only supported in Visual Studio 2005 (VC8) and GCC 3.0.0 or greater */
#if (_MSC_VER >= 1400 || __GNUC__ >= 3)
#define DEBUG_STRING(...) std::fprintf(stderr, __VA_ARGS__)
#define DEBUG_STRING_V(fmt,...) std::fprintf(stderr, "%s:%d: "fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#else
//#error "Your compiler doesn't support variadic macros"
#define DEBUG_STRING
#define DEBUG_STRING_V
#endif




Though I'd advise you to use them with restraint. They should only be used when you don't have any other choice. For example, they're great to use in kernel programming, because there aren't many debugging options.

Share this post


Link to post
Share on other sites
thanks for the code example :)
I was (ambiguously) refering to producing a process halting error with a message that'd be shown in the error prompt that pops up in Visual Studio though but I appreciate this example too :) and I didn't know you could have variadic macros already :-o7

still interested in a non m$-pimped version of the _Debug_message of m$' stl implementation.

using assert(fail && "...") meanwhile which is ok as long as you use JIT.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!