Re: g_return_if_fail() breakage



On Tue, 2002-11-26 at 17:32, Tim Janik wrote:
> On 26 Nov 2002, Matthias Clasen wrote:
> 
> > On Tue, 2002-11-26 at 02:40, Daniel Elstner wrote:
> >
> > > To fix this either g_return_if_fail() or G_LIKELY() should add parens.
> > > The latter is probably the safest option, even though we'd definitely
> > > lose the warning feature with -O0 or other compilers than GCC.
> >
> > Already fixed in CVS, thanks to our alert build sheriff Dan Mills.
> 
> adding parens is not a good idea, because of loosing compiler checks
> for x=5 instead of x==5 that way.
> a better fix is if (G_LIKELY (expr)) ; else g_log (...
> and not having G_LIKELY/G_UNLIKELY add extra parens.

If you consider the warning that important, you could either use gcc 3.x
or re-add the 

if (expr) { }
else
{
...
}

variants of g_return_if_fail() and friends for other compilers. 

Matthias




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