/* Debugging */
#ifdef DEBUG_THRU_UART0
# define DEBUG(...) printString (__VA_ARGS__)
#else
void dummyFunc(void);
# define DEBUG(...) dummyFunc()
#endif
I've seen this notation in different headers of C programming, I basically understood it's passing arguments, but I didn't understand what this "three dots notation" is called?
Can someone explain it with example or provide links also about VA Args?
It's a variadic macro. It means you can call it with any number of arguments. The three ...
is similar to the same construct used in a variadic function in C
That means you can use the macro like this
DEBUG("foo", "bar", "baz");
Or with any number of arguments.
The __VA_ARGS__ refers back again to the variable arguments in the macro itself.
#define DEBUG(...) printString (__VA_ARGS__)
^ ^
+-----<-refers to ----+
So DEBUG("foo", "bar", "baz");
would be replaced with printString ("foo", "bar", "baz")