Hi everyone. I need some help in writing a macro for 'if-condition' which compiles only when a DEBUG flag is defined by the #define directive.
Here is an example which illustrates what I want. first piece of code shows the usual way of writing an if condition with a #ifdef.
#ifdef DEBUG
if( rv == false )
{
string errorStr = "error in return value" ;
cout << errorStr << endl ;
throw( Exception(errorStr) ) ;
}
I want to write it in a way similar as below:
DEBUG_IF( rv==false )
{
same code as above
}
It seems to be simple but I am having trouble defining a macro which can do this. If someone has experienced this before, kindly help.
Thanks.