MantisBT - VCMI
View Issue Details
0001890VCMIOtherpublic2014-09-13 09:482017-05-25 19:55
josch 
 
normalminoralways
resolvedfixed 
x86_64Debian GNU/Linux8.0
 
 
0001890: warning: comparison between ‘enum QVariant::Type’ and ‘enum QMetaType::Type’
When compiling vcmi I receive the following warning:

/home/josch/vcmi-orig/launcher/jsonutils.cpp: In function ‘JsonNode JsonUtils::toJson(QVariant)’:
/home/josch/vcmi-orig/launcher/jsonutils.cpp:87:39: warning: comparison between ‘enum QVariant::Type’ and ‘enum QMetaType::Type’ [-Wenum-compare]
  else if (object.type() == QMetaType::QString)
                                       ^
/home/josch/vcmi-orig/launcher/jsonutils.cpp:89:39: warning: comparison between ‘enum QVariant::Type’ and ‘enum QMetaType::Type’ [-Wenum-compare]
  else if (object.type() == QMetaType::Bool)
                                       ^
$ cmake -DCMAKE_VERBOSE_MAKEFILE=true .
$ make
[...]
[100%] Building CXX object launcher/CMakeFiles/vcmilauncher.dir/jsonutils.cpp.o
cd /home/josch/vcmi-orig/launcher && /usr/bin/c++ -DM_BIN_DIR=\"/usr/local/bin\" -DM_DATA_DIR=\"/usr/local/share/vcmi\" -DM_LIB_DIR=\"/usr/local/lib/x86_64-linux-gnu/vcmi\" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DUSE_SYSTEM_MINIZIP -fPIE -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-strict-aliasing -Wno-switch -Wno-sign-compare -Wno-unused-local-typedefs -Wno-unused-parameter -Wuninitialized -Wno-overloaded-virtual -Wno-type-limits -fvisibility=hidden -O2 -g -DNDEBUG -fPIE -I/home/josch/vcmi-orig/launcher -I/home/josch/vcmi-orig -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -o CMakeFiles/vcmilauncher.dir/jsonutils.cpp.o -c /home/josch/vcmi-orig/launcher/jsonutils.cpp
/home/josch/vcmi-orig/launcher/jsonutils.cpp: In function ‘JsonNode JsonUtils::toJson(QVariant)’:
/home/josch/vcmi-orig/launcher/jsonutils.cpp:87:39: warning: comparison between ‘enum QVariant::Type’ and ‘enum QMetaType::Type’ [-Wenum-compare]
  else if (object.type() == QMetaType::QString)
                                       ^
/home/josch/vcmi-orig/launcher/jsonutils.cpp:89:39: warning: comparison between ‘enum QVariant::Type’ and ‘enum QMetaType::Type’ [-Wenum-compare]
  else if (object.type() == QMetaType::Bool)
                                       ^
/usr/bin/cmake -E cmake_progress_report /home/josch/vcmi-orig/CMakeFiles
No tags attached.
Issue History
2014-09-13 09:48joschNew Issue
2014-09-13 14:51IvanNote Added: 0004948
2014-09-13 16:26joschNote Added: 0004949
2017-05-25 19:55ChocimierNote Added: 0007044
2017-05-25 19:55ChocimierStatusnew => resolved
2017-05-25 19:55ChocimierResolutionopen => fixed

Notes
(0004948)
Ivan   
2014-09-13 14:51   
Not a bug or to be precise - not our bug. Docs for this method from Qt:

http://qt-project.org/doc/qt-4.8/qvariant.html#type [^]
>> Returns the storage type of the value stored in the variant. Although this function is declared as returning QVariant::Type, the return value should be interpreted as QMetaType::Type.
(0004949)
josch   
2014-09-13 16:26   
Then you should explicitly cast from "enum QVariant::Type" to "enum QMetaType::Type" to inform the compiler that "yes, I really want this to interpreted that way".
(0007044)
Chocimier   
2017-05-25 19:55   
Fixed:
https://github.com/vcmi/vcmi/commit/a3d4f9d22fd7de4715d8a0f9b3ab15b2fc2f8e96 [^]