[ccan] [PATCH] minmax: New module
David Gibson
david at gibson.dropbear.id.au
Mon Jun 2 22:38:41 EST 2014
On Mon, Jun 02, 2014 at 07:56:16AM -0400, Joel C. Salomon wrote:
> On Sun, Jun 1, 2014 at 11:24 PM, Rusty Russell <rusty at rustcorp.com.au>
> wrote:
>
> > The reason I never implemented this is because I was worried about
> > idempotency failure. Your functions double-evaluate, which bad form
> > even if they were named MIN and MAX and thus clearly macros.
> >
> > Unfortunately it's not possible to create an idempotent min or max
> > without gcc extensions which operates on 64 bit types (or whatever the
> > largest integer type is).
> >
>
> C11’s _Generic keyword should be able to help. Unlike C++, you need to
> write out all the functions and explicitly specify the overloading, but
> it’s possible.
Hm, ok. At the moment I've written it for gcc only, but maybe we can
extend it to C11 later.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20140602/b993597e/attachment.sig>
More information about the ccan
mailing list