From 30a29593e8c023cd2a200c1fdaac594c19264ac0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 23 Mar 2006 02:01:25 +0000 Subject: [PATCH] workaround for mingw 3.2.3 DLL build with wxUSE_STL=1 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38292 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/list.h | 38 +++++++++++++++++++++++++++++++++----- include/wx/listimpl.cpp | 8 ++++---- src/common/list.cpp | 2 +- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/include/wx/list.h b/include/wx/list.h index 5714dcd455..904bdfc5ba 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -135,15 +135,42 @@ private: #endif // defined( __VISUALC__ ) +/* + Note: the outer helper class _WX_LIST_HELPER_##liT below is a workaround + for mingw 3.2.3 compiler bug that prevents a static function of liT class + from being exported into dll. A minimal code snippet reproducing the bug: + + struct WXDLLEXPORT Foo + { + static void Bar(); + struct SomeInnerClass + { + friend class Foo; // comment this out to make it link + }; + ~Foo() + { + Bar(); + } + }; + + The program does not link under mingw_gcc 3.2.3 producing undefined + reference to Foo::Bar() function + */ + +// the real wxList-class declaration #define WX_DECLARE_LIST_XO(elT, liT, decl) \ + class WXDLLEXPORT _WX_LIST_HELPER_##liT \ + { \ + typedef elT _WX_LIST_ITEM_TYPE_##liT; \ + public: \ + static void DeleteFunction( _WX_LIST_ITEM_TYPE_##liT X ); \ + }; \ + \ VC6_WORKAROUND(elT, liT, decl) \ decl liT : public std::list \ { \ private: \ bool m_destroy; \ - private: \ - typedef elT _WX_LIST_ITEM_TYPE_##liT; \ - static void DeleteFunction( _WX_LIST_ITEM_TYPE_##liT X ); \ public: \ decl compatibility_iterator \ { \ @@ -269,7 +296,7 @@ private: void Erase( const compatibility_iterator& i ) \ { \ if ( m_destroy ) \ - DeleteFunction( i->GetData() ); \ + _WX_LIST_HELPER_##liT::DeleteFunction( i->GetData() ); \ erase( i.m_iter ); \ } \ bool DeleteNode( const compatibility_iterator& i ) \ @@ -288,7 +315,8 @@ private: void Clear() \ { \ if ( m_destroy ) \ - std::for_each( begin(), end(), DeleteFunction ); \ + std::for_each( begin(), end(), \ + _WX_LIST_HELPER_##liT::DeleteFunction ); \ clear(); \ } \ /* Workaround for broken VC6 std::list::sort() see above */ \ diff --git a/include/wx/listimpl.cpp b/include/wx/listimpl.cpp index a7d3729d08..7f3cdb7d18 100644 --- a/include/wx/listimpl.cpp +++ b/include/wx/listimpl.cpp @@ -12,10 +12,10 @@ #if wxUSE_STL #undef WX_DEFINE_LIST - #define WX_DEFINE_LIST(name) \ - void name::DeleteFunction( _WX_LIST_ITEM_TYPE_##name X ) \ - { \ - delete X; \ + #define WX_DEFINE_LIST(name) \ + void _WX_LIST_HELPER_##name::DeleteFunction( _WX_LIST_ITEM_TYPE_##name X ) \ + { \ + delete X; \ } #else // if !wxUSE_STL diff --git a/src/common/list.cpp b/src/common/list.cpp index 9cd9c1b90d..e25a2ad720 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -760,7 +760,7 @@ wxNode *wxStringList::Prepend(const wxChar *s) WX_DEFINE_LIST(wxObjectList) // with wxUSE_STL wxStringList contains wxString objects, not pointers -void wxStringListBase::DeleteFunction( wxString WXUNUSED(X) ) +void _WX_LIST_HELPER_wxStringListBase::DeleteFunction( wxString WXUNUSED(X) ) { } -- 2.45.2