[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: abort or verify?

From: Jim Correia <jim.correia_at_pobox.com>
Date: 2004-11-11 03:10:48 CET

On Nov 10, 2004, at 7:19 PM, Branko Čibej wrote:

> Yes, but the following would almost do the trick:
>
> #define verify(x) do { assert(x); if (!(x)) abort(); } while(1)

That will cause the macro argument to get evaluated twice if assert is
defined. This is bad news if it was an expression or function call.

You'd want to do something like this (written in my email client and
untested)

    #define verify_noerr(expression)
       \
       do
       \
       {
       \
           int evalOnce = (expression);
       \
           assert(evalOnce);
       \
           if (0 != evalOnce)
       \
           {
       \
                abort();
       \
           }
       \
       } while ( 0 )

Jim

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Nov 11 03:11:04 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.