Can't create macro for QTextStream manipulator functions
-
I'm creating some macros to ease transition from Qt5 to Qt6 for some of my shared code. For some reason, the QTextStream manipulator functions just don't want to be used in a macro!
Here's example 1, and under Qt6 the Qt::endl line causes compiler error: "MyLib::Qt has not been declared". This code is in my compat.h file which does not set a namespace. Why is it even referencing MyLib:: ?? Notice the SkipEmbyParts macro works fine.
// Example 1 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #define QT_COMPAT_SKIPEMPTYPARTS QString::SkipEmptyParts #define QT_COMPAT_ENDL "\n" #else #define QT_COMPAT_SKIPEMPTYPARTS Qt::SkipEmptyParts #define QT_COMPAT_ENDL Qt::endl #endifAnd here's example number 2, in this case the ::Qt::flush causes compiler error: "Unexpected qualified id before '::' token". I tried to prefix my manipulator with :: so that no higher level namespace would be assumed...but that chokes too.
// Example 2 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #define QT_COMPAT_FLUSH flush #else #define QT_COMPAT_FLUSH ::Qt::flush #endifCan someone help me fix my macros?
-
Hi,
Can you provide a minimal buildable example showing this ?
-
O ocgltd has marked this topic as solved on