2012年11月7日 星期三

[C] How to define one macro define in C language

#define Bingo(format, args...) sprintf(buf2, format, ## args); strcat(buf,buf2)

Two way to use

1. Bingo("%d", happy);

2. Bingo("You did a good job");

More example:
#define CHECK_ASSIGN(iface, fn, p_fn)                           \
    if ( (iface) && (iface->fn) )                                       \
    {                                                                   \
        p_fn = iface->fn;                                               \
    }   

Related Posts:

0 意見:

張貼留言