[ccan] [PATCH] minmax: New module
Rusty Russell
rusty at rustcorp.com.au
Wed Jun 4 11:24:48 EST 2014
"Joel C. Salomon" <joelcsalomon at gmail.com> writes:
> 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.
Yes, I thought the same thing :)
But for the moment the number of users without gcc extensions and with
C11 seems to be about 0 :(
Cheers,
Rusty.
More information about the ccan
mailing list