I have the following preprocessor divective:
#ifndef NDEBUG #define TRACE printf #else #define TRACE(...) #endif
and example of usage is:
TRACE('TRACE: some parameter = %i\n', param);
In C all works perfectly well when I build both debug and release versions, but in C++ compiler emits the following:
warning: invalid character in macro parameter name
error: badly punctuated parameter list in `#define’
and points these warning and error to the ‘TRACE(…)’ directive.
How to write this in C++ correctly?
You could do: