From: Rusty Russell <rusty@rustcorp.com.au>
To: Yubin Ruan <ablacktshirt@gmail.com>, ccan@lists.ozlabs.org
Subject: Re: useless expression in typesaft_cb_cast
Date: Tue, 13 Mar 2018 20:19:45 +1030 [thread overview]
Message-ID: <874llkl2yu.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20180311200527.GF6146@HP>
Yubin Ruan <ablacktshirt@gmail.com> writes:
> Hi,
>
> typesaft_cb_cast() is defined in typesaft_cb.h as:
>
> #define typesafe_cb_cast(desttype, oktype, expr) \
> __builtin_choose_expr( \
> __builtin_types_compatible_p(__typeof__(0?(expr):(expr)), \
> oktype), \
> (desttype)(expr), (expr))
>
> what is the point of that "0?(expr):(expr)" ?
Hi Yubin!
I had to search through git history to find it! It serves to
decay a function type to a function pointer, otherwise
__builtin_types_compatible_p(func, functype) returns false because
func isn't a pointer to a function, it's a function.
Cheers,
Rusty.
_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan
prev parent reply other threads:[~2018-03-13 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-11 20:05 useless expression in typesaft_cb_cast Yubin Ruan
2018-03-13 9:49 ` Rusty Russell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874llkl2yu.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=ablacktshirt@gmail.com \
--cc=ccan@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.