Eric Blake <[EMAIL PROTECTED]> writes:

> Simon Josefsson <simon <at> josefsson.org> writes:
>> Couldn't a replacement assert.h look like:
>> 
>> #include <stdio.h>
>> #include "progname.h"
>> 
>> #ifdef NDEBUG
>> # define assert(e) ((void) 0)
>> #else
>> # define assert(e)                                           \
>>   if (!(e)) {                                                        \
>>     fprintf (stderr, "%s: %s: %s: %s: Assertion failed.\n",  \
>>           program_name, __FILE__, __LINE__, __func__);       \
>
> Not quite.  Using if(){} will break if assert occurs as the sole statement 
> inside another if-else pair - use while(){} or ?: instead.  [...]

The C standard says that the assert macro expands to a void
expression, not to a statement, so a while or do-while loop is
out.
-- 
Ben Pfaff 
http://benpfaff.org



Reply via email to