_DEBUG is undefined:
dlog("Hi!") becomes nothing but generates "warning: ISO C99 requires rest arguments to be used"
dlog("Hi %s", "John") becomes nothing and does not complain.
_DEBUG is defined:
dlog("Hi!") becomes printf("%s:%d::%s " "Hi!" "\n", "comport_posix.cpp", 232, __func__, );
and generates "warning: ISO C99 requires rest arguments to be used". It also causes an error:
"error: expected primary-expression before ')' token"
dlog("Hi %s", "John") becomes printf("%s:%d::%s " "Hi %s" "\n", "comport_posix.cpp", 233, __func__, "John");
and works just fine.
How can I make a DEBUG macro which works in all four above cases?
(with, and without variable parameterlist in both debug and non-debug mode)
dlog() is defined as:
#ifdef _DEBUG
#define dlog(fmt,...) printf("%s:%d::%s " fmt "\n", __FILE__, __LINE__, __func__, __VA_ARGS__);
#else
#define dlog(fmt,...)
#endif