[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: abort vs. assert

From: Bruno Haible
Subject: Re: abort vs. assert
Date: Mon, 15 Mar 2010 22:36:26 +0100
User-agent: KMail/1.9.9

Hi Jim,

> You might just as well define and use your own macro,
>     #define ASSERT(e) do { if (!(e)) abort (); } while (0)

Oh yes, this one is perfectly fine with me.

> you assert a condition rather than testing its negation.

Good point. Yes, I too get confused when reading through a bunch
of negated assertions like

     if (index < 0 || index >= count)
       return -1;

>     #ifdef NDEBUG
>     # error "disable assertions herein at your peril -- and if you disable 
> then nonetheless, then don't report bugs"
>     #endif

Hehe, I guess I would attract some complaints if I was to publish such code ;-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]