Is it possible to create a null function that will not produce warnings?
Posted
by bbazso
on Stack Overflow
See other posts from Stack Overflow
or by bbazso
Published on 2010-03-17T20:38:29Z
Indexed on
2010/03/17
20:41 UTC
Read the original article
Hit count: 197
I have a logger in a c++ application that uses defines as follows:
#define FINEST(...) Logger::Log(FINEST, _FILE, __LINE, __func, __VA_ARGS_)
However what I would like to do is to be able to switch off these logs since they have a serious performance impact on my system. And, it's not sufficient to simply have my Logger not write to the system log. I really need to get rid of the code produced by the logs.
In order to do this, I changed the define to:
#define FINEST(...)
Which works, but this produces a whole bunch of warning in my code since variables are unused now. So what I would like to have is a sort of NULL FUNCTION that would not actually exist, but would not produce warnings for the unused variables.
So, said another way, I would like it to compile with no warnings (i.e. the compiler thinks that the variables are used for a function) but the function does not actually exist in the application (i.e. produces no performance hit).
Is this possible?
Thanks!
© Stack Overflow or respective owner