Building wxWidgets with RTTI disabled results in compiler or linker errors due to 'ms_wxDummy' not defined.
Repro on Windows with Visual Studio 2026:
The build ends with this error:
C:\project\wxWidgets\include\wx\event.h(571,5): error C7631: 'ms_wxDummy': variable with internal linkage declared but not defined
Repro on Linux with GCC 15.2:
The build ends with these errors:
wxrc.cpp:(.text._ZN20wxObjectEventFunctor14ms_wxClassInfoEv[_ZN20wxObjectEventFunctor14ms_wxClassInfoEv]+0x2): undefined reference to `wxObjectEventFunctor::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxObject*>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<bool>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplConstCharPtr::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplConstWchar_tPtr::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxDateTime>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplwxString::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxArrayString>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxAnyNullValue>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplInt::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplDouble::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxUniChar>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplVariantData::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<void*>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxAnyList>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImpl<wxVariant>::ms_wxDummy'
/usr/bin/ld: /home/test/bug/wxWidgets/lib/libwx_baseu-3.3.so: undefined reference to `wxAnyValueTypeImplUint::ms_wxDummy'
The culprit is the macro definition below in include/wx/typeinfo.h. A static member named ms_wxDummy is declared, but never defined.
// Use this macro to declare type info fully inline in class.
#define WX_DECLARE_TYPEINFO_INLINE(CLS) \
private: \
static char ms_wxDummy; \
static void ms_wxClassInfo() { ms_wxDummy = 0; } \
_WX_DECLARE_TYPEINFO_CUSTOM(CLS, ms_wxClassInfo)
I do not see the purpose of ms_wxDummy. I propose removing it with the change below. With this change, I see no build errors.
diff --git a/include/wx/typeinfo.h b/include/wx/typeinfo.h
index 4b54b94157..25134b349f 100644
--- a/include/wx/typeinfo.h
+++ b/include/wx/typeinfo.h
@@ -129,8 +129,7 @@ void CLS::ms_wxClassInfo() { ms_wxDummy = 0; }
// Use this macro to declare type info fully inline in class.
#define WX_DECLARE_TYPEINFO_INLINE(CLS) \
private: \
- static char ms_wxDummy; \
- static void ms_wxClassInfo() { ms_wxDummy = 0; } \
+ static void ms_wxClassInfo() { } \
_WX_DECLARE_TYPEINFO_CUSTOM(CLS, ms_wxClassInfo)
#define wxTypeId(OBJ) (OBJ).GetWxTypeId()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
This is usually done to force linking with the object file defining the variable and which could/would be otherwise omitted by the linker when using static linking, but I agree that this doesn't make much sense for an "inline" version of the macro, so I guess we should apply this. If you can, please check if this still works with static linking too. TIA!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I tested both static and dynamic on Windows and Linux, both building as well as running. I was not able to build on macOS with --enable-no_rtti due to dynamic_cast that are not guarded. So I tested with clang on Linux. Saw no problems.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks for testing, will push this soon.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()