On 29 July 2013 12:57, Ben Pfaff <b...@nicira.com> wrote:
> In C, one can do preprocessor tricks by making a macro expansion include
> the macro's own name.  We actually used this in the tree to automatically
> provide function arguments, e.g.:
>
>     #define f(x) f(x, __FILE__, __LINE__)
>     int f(int x, const char *file, int line);
>
> ...
>
>     f(1);    /* Expands to a call like f(1, __FILE__, __LINE__); */
>
> However it's somewhat confusing, so this commit stops using that trick.
>
> Reported-by: Ed Maste <ema...@freebsd.org>
> Signed-off-by: Ben Pfaff <b...@nicira.com>

Acked-by: Ed Maste <ema...@freebsd.org>

One minor comment:

>        #define f(x) f(x, __FILE__, __LINE__)
>        int f(int x, const char *file, int line);

Unlike the instances in the source, the example as-is doesn't compile,
which I think helps provide justification for the removal of the trick
:-)

It's missing either an #undef, or the further trick of relying on the
preprocessor only expanding function-like macros if the token
following is a left parenthesis, resulting in the odd-looking int
(f)(int x, const char *file, int line) syntax.
X-CudaMail-Whitelist-To: dev@openvswitch.org
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to