<<< Date Index >>>     <<< Thread Index >>>

Re: Little code cleanup



On Fri, Mar 07, 2008 at 03:59:30PM +0100, Vincent Lefevre wrote:
> -# define NONULL(x) x?x:""
> +# define NONULL(x) ((x) != (void *) 0) ? (x) : ""

Both those definitions are absolutely horrid:
Consider:
    *NONULL(foo)
    1 + NONULL(foo) + 1
    NONULL(a == b ? c : d)

I did once have to fight a compiler that optimised out the check:
        extern int foo;
        if (&foo != NULL) ...

        David

[Hint look up weak elf symbols]

-- 
David Laight: david@xxxxxxxxx