I love my asserts. I use them like crazy throughout my code and catch errors faster than you and your whole testing department. :> The computer does exactly what I ASK of it, which sometimes is not the same as what I EXPECT of it. So I wrap up my expectations with assert macros so my computer friend and I stay on the same page. Happy happy joy joy.

In Qt, we have the Q_ASSERT macro. Qt default behavior is to abort on any Q_ASSERT macro failure. This is weird to me (even if it is common). Almost universally, I want to SEE what’s going on when I hit an assert. Sometimes the assertion turns out to be wrong and may need adjusting. Even if it’s right, sometimes it’s helpful to check the effect of the failed assertion. And certainly, being able to walk back up the stack trace is critical to determine where things went wrong. I can kill the program easily if I WANT to, but I may want to continue – it should be my choice. It’s a no-brainer!

So I don’t use Q_ASSERT. Here’s my cross-platform C++ assert macro hackery. It’s not perfect but it’s getting me by so far… (continued…)