Re: [Warzone-dev] assert return macro

2009-02-02 Thread Giel van Schijndel
On Mon, Feb 02, 2009 at 08:58:11AM +0100, Per Inge Mathisen wrote: On Sun, Feb 1, 2009 at 11:55 PM, Giel van Schijndel m...@mortis.eu wrote: It is misleading, though, since it can also be ASSERT_AND_RETURN or just RETURN, depending on how the program is compiled and how gdb reacts to abort

Re: [Warzone-dev] assert return macro

2009-02-01 Thread Giel van Schijndel
On Sat, Jan 31, 2009 at 11:45:11PM +0100, Per Inge Mathisen wrote: No. There are in fact three places now that the expression result is checked: 1) Checking if we should log an error 2) The assert() 3) The return condition In my patch I only cache it in the first case for the last case,

Re: [Warzone-dev] assert return macro

2009-02-01 Thread Per Inge Mathisen
On Sun, Feb 1, 2009 at 11:55 PM, Giel van Schijndel m...@mortis.eu wrote: I'd rather not use assert(false) as on some systems assert() is used to produce a nice GUI message. E.g. on Windows you'll get a message like assertion $expression failed, abort, ignore, attach debugger?. Deciding which

Re: [Warzone-dev] assert return macro

2009-01-31 Thread Giel van Schijndel
On Thu, Jan 29, 2009 at 08:49:39PM +0100, Per Inge Mathisen wrote: I want to define a new macro ASSERT_RETURN(expr, retval, ...) that asserts in debug builds, and returns with the given return value in non-debug builds. This to make it easier to do the right thing when coding, which is to

Re: [Warzone-dev] assert return macro

2009-01-31 Thread bugs buggy
On 1/31/09, Per Inge Mathisen per.mathi...@gmail.com wrote: On Sat, Jan 31, 2009 at 7:43 AM, bugs buggy buginato...@gmail.com wrote: I was thinking we may do something like a ASSERT_ENTER() as well How would it work? It wouldn't work in all functions, just functions that have a known

Re: [Warzone-dev] assert return macro

2009-01-31 Thread Per Inge Mathisen
On Sat, Jan 31, 2009 at 4:05 PM, Giel van Schijndel m...@mortis.eu wrote: I like the general idea. About your patch, assert() itself performs string expansion on the given expression as well (for display purposes). Doesn't caching the expression's result cause assert() to see another string,

Re: [Warzone-dev] assert return macro

2009-01-30 Thread bugs buggy
On 1/29/09, Per Inge Mathisen per.mathi...@gmail.com wrote: I want to define a new macro ASSERT_RETURN(expr, retval, ...) that asserts in debug builds, and returns with the given return value in non-debug builds. This to make it easier to do the right thing when coding, which is to first

[Warzone-dev] assert return macro

2009-01-29 Thread Per Inge Mathisen
I want to define a new macro ASSERT_RETURN(expr, retval, ...) that asserts in debug builds, and returns with the given return value in non-debug builds. This to make it easier to do the right thing when coding, which is to first check an entry condition with an assert, and then check it again to