I have the following macro in a logging library of mine :
#define TRACE_E(__logCat,__format,...) \
do { \
::dbg::LogCategory * const __catPtrVal = (::dbg::LogCategory *)(__logCat); \
if( NULL != __catPtrVal && __catPtrVal->IsEnabled() ) \
{ \
__catPtrVal->Error( __format, __VA_ARGS__ ); \
} \
} while( false )
Under Visual Studio (2008) it works as intended, i.e i can do both TRACE_E( pLog, "some message without parameters" );
and TRACE_E( pLog, "some message with parameters %d %d", 4, 8 );
But when using this same library with eclipse and the Android NDK i'm getting a compilation error if i don't pass at least one parameter after the format string in my macro, i.e TRACE_E( pLog, "some message without parameters" );
is not valid, but TRACE_E( pLog, "some message without parameters", 0 );
is, which forces me to pass a dummy parameter when none is needed.
Is there any difference of behaviour with variadic macros when using g++ rather than Visual Studio's compiler ? Thank you.