E
E
Evgeny Ivanovich2015-06-29 07:01:42
Qt
Evgeny Ivanovich, 2015-06-29 07:01:42

What is the correct way to write this macro in C++/Qt?

In general, there is such a primitive overlap construction
#ifdef QT_DEBUG
#define __DEBUG(A, B) qDebug() << PLACE(A) << B;
#else
#define __DEBUG(A, B)
#endif
Its essence is that if you compile the project in debug mode, then the macro works and the corresponding value is substituted, but if you compile in Release mode, then the macro does not substitute anything. Question: how to correctly implement such a construction without varnings?
/defines.h:55: warning: "__DEBUG" redefined [enabled by default]
#define __DEBUG(A, B) qDebug() << PLACE(A) << B;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2015-06-29
@Pauk_Code

For example like this:

#undef __DEBUG
#ifdef QT_DEBUG
#define __DEBUG(A, B) qDebug() << PLACE(A) << B;
#else
#define __DEBUG(A, B)
#endif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question