Aaron Ardiri wrote:
>
> this is what i would recommend as well :) 
>
> #define myMemMove(a,b,c,d) \
>   MemPtrDataStorage((a)) ? DmWrite((a),(b),(c),(d)) \
>                          : MemMove((a)+(b),(c),(d))
> 
> kill the { } and ; *g* not needed, and, always () around your 
> arguments, for safety :) you here it doesn't matter with a+b, 
> but, with a*b, it would:

You neglected to enclose the ?: expression in parentheses.  For example,
consider:

    #define FOO(a, b, c) \
        (a) ? (b) : (c)

    int x;
    x = 4 * FOO(1, 2, 3);

The value of x is now 2, not 8 as one would expect.


Alan Ingleby wrote:
>
> #define SafeUlgyDmWrite(a,b,c,d)
> {MemPtrDataStorage(a)?DmWrite(a,b,c,d):MemMove(a+b,c,d);} 

As Aaron already pointed out, the braces are totally unnecessary.  Furthermore,
the following would generate a syntax error:

    if (condition)
        SafeUglyDmWrite(a, b, c, d);
    else
        /* ... */

If you do need to use braces in macros, you need to enclose them in a do-while
block:

    #define BAR(x, y) \
        do            \
        {             \
            /* ... */ \
        } while (0) /* semicolon intentionally omitted */


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to