]> git.saurik.com Git - wxWidgets.git/commitdiff
workaround for mingw 3.2.3 DLL build with wxUSE_STL=1
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Mar 2006 02:01:25 +0000 (02:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 23 Mar 2006 02:01:25 +0000 (02:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38292 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/list.h
include/wx/listimpl.cpp
src/common/list.cpp

index 5714dcd455d1aba3978661bbc1b93412f2393977..904bdfc5bacc7dbc753805d3221edc6b79f1a506 100644 (file)
@@ -135,15 +135,42 @@ private:
 
 #endif // defined( __VISUALC__ )
 
 
 #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)                                    \
 #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<elT>                                          \
     {                                                                         \
     private:                                                                  \
         bool m_destroy;                                                       \
     VC6_WORKAROUND(elT, liT, decl)                                            \
     decl liT : public std::list<elT>                                          \
     {                                                                         \
     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                                           \
         {                                                                     \
     public:                                                                   \
         decl compatibility_iterator                                           \
         {                                                                     \
@@ -269,7 +296,7 @@ private:
         void Erase( const compatibility_iterator& i )                         \
         {                                                                     \
             if ( m_destroy )                                                  \
         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 )                    \
             erase( i.m_iter );                                                \
         }                                                                     \
         bool DeleteNode( const compatibility_iterator& i )                    \
@@ -288,7 +315,8 @@ private:
         void Clear()                                                          \
         {                                                                     \
             if ( m_destroy )                                                  \
         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 */           \
             clear();                                                          \
         }                                                                     \
         /* Workaround for broken VC6 std::list::sort() see above */           \
index a7d3729d087df341504e8611a647a43ccea48176..7f3cdb7d186b0fe9a3e91da2de82461b9e28978b 100644 (file)
 #if wxUSE_STL
 
     #undef  WX_DEFINE_LIST
 #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
         }
 
 #else // if !wxUSE_STL
index 9cd9c1b90d77cd51a8d933604f9991bf7d0fd75b..e25a2ad720e02e86fa93fc75622b79dd5cd6b11d 100644 (file)
@@ -760,7 +760,7 @@ wxNode *wxStringList::Prepend(const wxChar *s)
     WX_DEFINE_LIST(wxObjectList)
 
 // with wxUSE_STL wxStringList contains wxString objects, not pointers
     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) )
 {
 }
 
 {
 }