[Top][All Lists]

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

Re: abort() traceability

From: Ben Pfaff
Subject: Re: abort() traceability
Date: Mon, 15 Jun 2009 14:17:50 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> Sam Steingold <address@hidden> writes:
>> Ben Pfaff wrote:
>>> Bruno Haible <address@hidden> writes:
>>>> What do the others think? Should we possibly extend stdlib.in.h so that
>>>> abort() becomes a macro that produces a detailed error message, similar to
>>>> what assert() does?
>>> Just changing abort() to assert(0) would improve the diagnostics
>>> significantly.
>> Sounds good.
>> Actually,
>> assert(foo())
>> instead of
>> if (!foo()) assert(0)
>> wil probably produce an even better error message.
> Unless you build with NDEBUG, in which case the entire assert(foo()) is
> a no-op...

Of course there are many alternatives.  A few of them:

  - Make sure that NDEBUG doesn't affect this file:

      #undef NDEBUG
      #include <assert.h>

  - Belt and suspenders:

      #include <assert.h>
      #define NOT_REACHED() do { assert(0); abort(); } while (0)

  - Hand coding:

      static void
      fail_hard(const char *msg)
        fputs (msg, stderr);
        abort ();
Ben Pfaff 

reply via email to

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