Digital Paint Discussion Board

Development => General Development => Topic started by: jitspoe on May 22, 2008, 01:41:12 AM

Title: How do I Make Asserts Behave the Way They Should on Linux?
Post by: jitspoe on May 22, 2008, 01:41:12 AM
So apparently Linux and/or gcc thinks asserts should terminate a program completely instead of just triggering a breakpoint and allowing me to step through it with a debugger.  How do I make them behave correctly?
Title: Re: How do I Make Asserts Behave the Way They Should on Linux?
Post by: Krizdo4 on May 25, 2008, 11:01:40 PM
I'm not sure about the "right" way to do this but here's a suggestion.

Code: [Select]
#include <signal.h>

#undef assert
#define assert(expression)  \
  ((void) ((expression) ? 0 : raise(SIGTRAP)))


http://en.wikipedia.org/wiki/SIGTRAP (http://en.wikipedia.org/wiki/SIGTRAP)
Title: Re: How do I Make Asserts Behave the Way They Should on Linux?
Post by: jitspoe on May 27, 2008, 06:46:36 PM
Thanks - I'll look into that.