QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]
-
Hi
I am currently using Qt 5.9.6 with GCC compiler , i have created a simple sample app which shows the mainwindow, but getting lot of compiler warnings.
#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
warnings:
/home/rajakumara/Qt5.9.6/5.9.6/gcc_64/bin/uic ../DEP_TEST/mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../DEP_TEST -I. -I../Qt5.9.6/5.9.6/gcc_64/include -I../Qt5.9.6/5.9.6/gcc_64/include/QtWidgets -I../Qt5.9.6/5.9.6/gcc_64/include/QtGui -I../Qt5.9.6/5.9.6/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I../Qt5.9.6/5.9.6/gcc_64/mkspecs/linux-g++ -o main.o ../DEP_TEST/main.cpp
In file included from ../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qlocale.h:43,
from ../Qt5.9.6/5.9.6/gcc_64/include/QtGui/qguiapplication.h:47,
from ../Qt5.9.6/5.9.6/gcc_64/include/QtWidgets/qapplication.h:52,
from ../Qt5.9.6/5.9.6/gcc_64/include/QtWidgets/QApplication:1,
from ../DEP_TEST/main.cpp:2:
../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qvariant.h: In constructor ‘QVariant::QVariant(QVariant&&)’:
../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qvariant.h:265:25: warning: implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]
265 | { other.d = Private(); }
| ^
../Qt5.9.6/5.9.6/gcc_64/include/QtCore/qvariant.h:380:16: note: because ‘QVariant::Private’ has user-provided ‘QVariant::Private::Private(const QVariant::Private&)’
380 | inline Private(const Private &other) Q_DECL_NOTHROW
^~~~~~~Thanks in Advance.
-
Use a newer Qt version or an older gcc or disable the warning via QMAKE_CXXFLAGS.
-
i tried gcc version -8 above the warnings are not showing up.but the warning exists in gcc version -9 and version-10.
If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
GCC.Thanks in Advance.
-
i tried gcc version -8 above the warnings are not showing up.but the warning exists in gcc version -9 and version-10.
If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
GCC.Thanks in Advance.
@Rajakumar_QT said in QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]:
If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
GCC.Most likely this has to do with the ever changing C++ standard. My guess is that the C++ standard deprecated this behavior. Newer versions of GCC know about this and give a corresponding warning. Older versions of Qt couldn't have been written against future standards. And older versions of Qt are also not updated to conform to newer C++ standards. This is what current versions of Qt are for. Usually, Qt states which compiler versions are supported for which Qt version. You have to match the two to avoid any warnings. Thus: Either use an older compiler or use a more recent version of Qt.
One other trick is to disable warnings around the corresponding include of the Qt header. Compilers usually have something like a
#pragma
to turn warnings off and on again and this would be used right before and after the#include
of the Qt header in question. Though you should have additional guards (#ifdef
s) that apply the#pragma
only for GCC (not other compilers) and only specific older versions of Qt (if you decide to later switch to a newer version of Qt somewhere far in the future, you still want the compiler to give as many warnings as possible). -
i tried gcc version -8 above the warnings are not showing up.but the warning exists in gcc version -9 and version-10.
If possible can u please share me a link or description which explains why this warnings are shown in when we use lower version of QT with higher version
GCC.Thanks in Advance.
@Rajakumar_QT said in QT 5.9.6 - getting lot of compiler warnings - implicitly-declared ‘constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)’ is deprecated [-Wdeprecated-copy]:
explains why this warnings are shown
Because the newer compiler added this warning as you see by yourself.
Simply disable the warning if you don't like it as I wrote above. -
thanks for the support