Build errors with Qt 6.7.0
-
Hello all,
I have just upgraded to 6.7.0 and my builds (both MinGW and MSVC22019) are now littered with the following 3 build issue when I build my subdirs projects.
Is anyone getting the same issue? Any thoughts/guidance would be very welcome.
Errors:
C:\Qt\6.7.0\msvc2019_64\include\QtCore\qcompare.h:228: error: C2248: 'Qt::partial_ordering::partial_ordering': cannot access private member declared in class 'Qt::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(228): error C2248: 'Qt::partial_ordering::partial_ordering': cannot access private member declared in class 'Qt::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(189): note: see declaration of 'Qt::partial_ordering::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(65): note: see declaration of 'Qt::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore\qcompare.h:408: error: C2248: 'Qt::partial_ordering::partial_ordering': cannot access private member declared in class 'Qt::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(408): error C2248: 'Qt::partial_ordering::partial_ordering': cannot access private member declared in class 'Qt::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(189): note: see declaration of 'Qt::partial_ordering::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(65): note: see declaration of 'Qt::partial_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore\qcompare.h:411: error: C2248: 'Qt::weak_ordering::weak_ordering': cannot access private member declared in class 'Qt::weak_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(411): error C2248: 'Qt::weak_ordering::weak_ordering': cannot access private member declared in class 'Qt::weak_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(377): note: see declaration of 'Qt::weak_ordering::weak_ordering'
C:\Qt\6.7.0\msvc2019_64\include\QtCore/qcompare.h(220): note: see declaration of 'Qt::weak_ordering'KR
CodePoet
-
Hi and welcome to devnet,
I remember threads on the development mailing list about these elements. Can you reduce your code to a minimal state that triggers this issue ? You might also want to check the bug report system to see if there's already something related.
-
I have the same issue. I have posted a bug report here:
https://bugreports.qt.io/browse/QTBUG-123934 -
We were having this issue in just one of our projects. We use Visual Studio 2022 17.9.5 Professional with toolset v143.
Our problem was having
using namespace std;
before#include <QDateTime>
Putting
using namespace std;
after all our includes fixed the issue. -
This is apparently not a Qt bug. You could blame MS Visual Studio for not being smart enough to figure out the partial_ordering's namespace ownership. However, after all, it is your code that confuses the MS Visual Studio.
The answer is obvious, you have written somewhere in your .h files "using namespace std;". And since std::partial_ordering is made available in c++20, it caused a naming collision with Qt 6.7's partial_ordering.
Here's a guide how to fix the issue. Search in your project of "using namespace std;" in all header files. Avoid using "using namespace std;", at least not in the header files!
Explicitly write code like std::string instead of string, etc. Alternatively, you might be able to take a shortcut by adding alias e.g. "using string = std::string;" or other alias whereever you need.
Bottomline, don't simply pollute your code base with "using namespace std;"
It should solve your problem.