qDebug macro substitution
I want to create a macro that expands to qDebug, so I suppress the qDebug output in release build.
How can I do it correctly?
I tried with:
Code:
#ifdef MY_DEBUG
#define QDEBUG(x) qDebug(x)
#else
#define QDEBUG(x)
#endif
but I have a problem with multiple qDebug parameters like:
Code:
qDebug ( "ENTER in DeviceConfiguration = %s\n", moduleName.ascii() );
Any help?
Thanks,
the_bis
Re: qDebug macro substitution
This works for me (using TRACE instead of QDEBUG, of course):
Code:
#ifdef DEBUG
#define TRACE qDebug
#else
#define TRACE(fmt,arg...) ((void)0)
#endif
Re: qDebug macro substitution
Yes! It works!
My project.pro is now:
Code:
[...]
CONFIG += qt warn_on debug
[...]
debug {
DEFINES += MY_DEBUG
}
[...]
and my project.cpp is now:
Code:
#ifdef MY_DEBUG
#define QDEBUG qDebug
#else
#define QDEBUG(fmt,arg...) ((void)0)
#endif
[...]
QDEBUG ( "Value now is %s\n", varResult.ascii() );
[...]
Thank you very much,
the_bis