hi,
A few days ago, when I was tracing linux driver code. I found some debug macros
like:
#define dbg(fmt, args...) do { printk(KERN_INFO fmt, ## args); } while(0)
#define print_dbg(f, arg...) printk(KERN_DEBUG __FILE__ ": " f "\n", ## arg)
I checked the C grammar in the appenix of "The C Programming Language, 2ed", and
the variable-length arg list is like:
parameter-type-list:
parameter-list
parameter-list, ...
It looks like the "..." must be at the end of arg and there must be a ',' before it.
And I wrote a little test program:
#define BUG(fmt...) do {printf(fmt);} while (0)
the fmt is followed by "..." without a ',' before it, but the macro wroked well.
I found it is very useful when debugging, but I have no idea why and how
these macros work. Can someone explain this?
Thanks a lot :-)
best regards,
Min-Hua