[ccan] [PATCH] minmax: New module

Joel C. Salomon joelcsalomon at gmail.com
Mon Jun 2 21:56:16 EST 2014


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.

—Joel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20140602/debfcc52/attachment.html>


More information about the ccan mailing list