Re: RFC: libkern version of inet_ntoa_r

From: Arnaud Lacombe <lacombar_at_gmail.com>
Date: Sun, 29 Jul 2012 15:38:59 -0400
Hi,

On Sun, Jul 29, 2012 at 3:19 PM, Luigi Rizzo <rizzo_at_iet.unipi.it> wrote:
> Remapping f(a) into f(a, b) requires both a macro
> and a wrapping function, something like this
>
>         T __f(T1 a, T2 b) { return f(a, b); }
>         #define f(a) __f(a, b)
>
This can be done way more easily:

void fn(int a, int b)
{
        printf("%d %d\n", a, b);
}

#define fn(x)   ({ fn(x, 42); })

int main(int argc, char **argv)
{

        fn(0);
        return 0;
}

works just fine.

> but i am not so interested in participating to the IOCCC :)
>
maybe you should ;-)

 - Arnaud

ps: this construct is used all over the Linux kernel compatibility libraries.
Received on Sun Jul 29 2012 - 17:39:01 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC