Issue
I am working on a cross platform Qt project and recently used dynamic_cast
, which worked just fine under Linux. But our CI could not compile the code for Windows with the error message:
error: ‘dynamic_cast’ not permitted with -fno-rtti
I found that in our project CONFIG += rtti_off
was set. According to Qt documentation rtti_off
means:
RTTI support is disabled. By default, the compiler default is used.
There is nothing written about platform specific behavior of the flag (or at least I did not find it).
grep -ir rtti
in Qt's mkspecs gave:
features/win32/rtti.prf:CONFIG -= rtti_off
features/win32/rtti.prf:QMAKE_CFLAGS += $$QMAKE_CFLAGS_RTTI_ON
features/win32/rtti.prf:QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RTTI_ON
features/win32/rtti_off.prf:CONFIG -= rtti
features/win32/rtti_off.prf:QMAKE_CFLAGS += $$QMAKE_CFLAGS_RTTI_OFF
features/win32/rtti_off.prf:QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RTTI_OFF
common/g++-win32.conf:QMAKE_CXXFLAGS_RTTI_ON = -frtti
common/g++-win32.conf:QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti
common/winrt_winphone/qmake.conf:CONFIG = package_manifest $$CONFIG incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target rtti
common/winrt_winphone/qmake.conf:QMAKE_CXXFLAGS_RTTI_ON = -GR
common/winrt_winphone/qmake.conf:QMAKE_CXXFLAGS_RTTI_OFF =
common/msvc-desktop.conf:QMAKE_CXXFLAGS_RTTI_ON = -GR
common/msvc-desktop.conf:QMAKE_CXXFLAGS_RTTI_OFF =
So these flags are obviously only checked for Windows platforms.
My questions
- Why is it done only for Windows?
- Is this documented anywhere?
- If so, where?
- If not, why?
Edit
To clarify: I am using mingw32-gcc under Windows and gcc under Linux. Both version have the capability to deactivate RTTI using the flag -fno-rtti
. This flag is integrated into the generated Makefile if I run qmake with target platform win32-g++
, but not with linux
. Hence the questions above.
Solution
This is QTBUG-26595, which was resolved in Qt 5.12.1.
Answered By - orgads Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.