QCustomPlot Discussion and Comments

QT 6.4.2 debug\moc_qcustomplot.cpp(360): error C2882: 'QCP': illegal use of namespace identifier in expressionReturn to overview

debug\moc_qcustomplot.cpp(360): error C2882: 'QCP': illegal use of namespace identifier in expression
(MSVC 2019)

Same with gcc in msys2 or others. Apparently the moc processing has changed, and the Q_MOC_RUN define evaulation does not work as before.

Anyone any ideas how to fix this?

Oliver

Hi Oliver,

Thanks for bringing this up. Is this new behavior since Qt6.4.2? Because the release tests ran fine for Qt6.4.0 (which was the current Qt version when QCP 2.1.1 was released), and it would be quite weird for them to break moc in a Qt patch version (but not impossible).

Anyway, I'll test it out later to see what's going on.

It seems not to be a moc issue, but rather a changed output the moc creates. It is creating a template with QPC as template argument, and QPC is a namespace in this context.

Oliver

I was able to get this managed. The issue is the naming of the Namespace the same as a class called QCP. When you rename the namespace to eg Q_CP it works with Qt 6.4.3.

In customplot.h there is
#if QT_VERSION >= 0x060200
as I use QT 6.8 in VS2022 kind of both, the then and the else part is active. I assume during compiling and during moc different branches are used. When I manually set
#define QT_VERSION 0x060800
right before the line above, everything works fine. Don't know where the wrong QT version definition comes in.

a better solution for QT 6.8, as it states in the comment:
#if QT_VERSION >= 0x060200 // don't use QT_VERSION_CHECK here, some moc versions don't understand it
i gave QT_VERSION_CHECK a chance, so I replaced this line by
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
and then it worked