I need to print msg1 and msg2 for the same error when compiled with and without DEBUG flag. E.g.
fprintf( stderr,
#ifdef DEBUG
"error msg1 %s",__FILE__
#else
"error msg2"
#endif
);
or other way might be to pass these msg1 and msg2 to a function and print it using vfprintf().
Probably, The second method would have run time overhead. So, I am just wondering what could be better way of doing this?
E.g. A use case might be that the code need to be compiled with info and debug flags. info might be user related messages and debug for debugging purpose.
Any suggestions?
Usualy the traces are used in the code to help debug it, so for example in your NULL pointer tests you can add smth like
if (ptr==NULL) DEBUG("Entering Null pointer");. I'am just telling you that because i don't udrestand why you want use bothmsg1andmsg2.For me i usually use a macro
DEBUGand a global variableverbose:Example :
Hope i help.