Re: snag of G_LIKELY()
- From: Daniel Elstner <daniel elstner gmx net>
- To: Mark Mielke <mark mark mielke cc>
- Cc: gtk-devel-list gnome org
- Subject: Re: snag of G_LIKELY()
- Date: 23 Nov 2002 22:12:47 +0100
Am Sam, 2002-11-23 um 21.43 schrieb Mark Mielke:
> I think I missed the point... why shouldn't it be:
Yes :)
> #define G_LIKELY(expr) __builtin_expect(!(expr), 0)
> #define G_UNLIKELY(expr) __builtin_expect((expr), 0)
It has to be a double bang in this example because the logic would be
changed otherwise. Remember, G_LIKELY() is used in an if() expression,
i.e. the return value of the expression matters.
But the real point of this discussion and my initial mail is that
g_return_if_fail(a = b);
used to trigger a helpful GCC warning. But since the introduction of
G_LIKELY() the warning isn't triggered anymore because the macro *has
to* add parentheses.
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]