I am moving some C++ code to OS X (Maverick) which was previously compiled on Win VC++ 2012 and Linux GCC 4.7 .I have the following macro to print messages to console in debug mode:
#ifdef DEBUG
#define PrintDebug(msg) Msg::PrintMsg msg
#else
#define PrintDebug(msg) (void)0
#endif
It worked but in XCode the compiler(clang) spits errors like "expected ';' after expression" and "too many arguments provided to function like macro invocation"
Important to note,the input to the macro argument has the same format as
printf(fmt,...)
For example using it with message only:
PrintDebug("Some message\n");
throws compile time error: "expected ';' after expression"
And when I pass the formatting:
PrintDebug("Number:%d\n",someNumber);
the error is :too many arguments provided to function like macro invocation
I tried several other variations from this SO thread but didn't find a match which would work with all 3 compilers. How do I get it working with CLANG but also be compatible with MSVC and GCC compilers?