]> git.saurik.com Git - wxWidgets.git/commitdiff
added WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE() macro and use it to work around VC6 warnin...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 14 Sep 2007 21:02:09 +0000 (21:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 14 Sep 2007 21:02:09 +0000 (21:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/buffer.h
include/wx/dlimpexp.h
include/wx/string.h

index c4cb0dc2087e850053f4afdfa0867afe32cda30b..a18b85c7626ebe4c39b3deab96db8d6e7ffd8b30 100644 (file)
@@ -150,6 +150,8 @@ private:
     bool m_owned;
 };
 
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<char> )
+
 class WXDLLIMPEXP_BASE wxCharBuffer : public wxCharTypeBuffer<char>
 {
 public:
@@ -165,6 +167,8 @@ public:
 };
 
 #if wxUSE_WCHAR_T
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<wchar_t> )
+
 class WXDLLIMPEXP_BASE wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
 {
 public:
index 3df4f4e603b851f0ec17604a255eb413ccc928ff..f6effd34446982c854ba7ec6557f4f97ea0a690f 100644 (file)
 #define WXDLLEXPORT WXDLLIMPEXP_CORE
 #define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE
 
+/*
+   MSVC up to 6.0 needs to be explicitly told to export template instantiations
+   used by the DLL clients, use this macro to do it like this:
+
+       template <typename T> class Foo { ... };
+       WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> )
+
+   (notice that currently we only need this for the wxBase library)
+ */
+#if defined(__VISUALC__) && (__VISUALC__ <= 1200)
+    #ifdef WXMAKINGDLL_BASE
+        #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
+            template class WXDLLIMPEXP_BASE decl;
+    #else
+        /*
+           We need to disable this warning when using this macro, as
+           recommended by Microsoft itself: 
+
+           http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958
+         */
+        #pragma warning(disable:4231)
+
+        #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
+            extern template class WXDLLIMPEXP_BASE decl;
+    #endif
+#else /* not VC <= 6 */
+    #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
+#endif /* VC6/others */
+
 #endif /* _WX_DLIMPEXP_H_ */
 
index 87bd52c54ad7326622ca0524ab6736a77624e50b..3b112d582da2b45e99f3a04afddf9c9059d46d0f 100644 (file)
@@ -2834,6 +2834,9 @@ public:
 };
 
 #if wxUSE_STL_BASED_WXSTRING
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase<wxStringCharType> )
+
 class wxStringInternalBuffer : public wxStringTypeBufferBase<wxStringCharType>
 {
 public:
@@ -2845,7 +2848,11 @@ public:
     DECLARE_NO_COPY_CLASS(wxStringInternalBuffer)
 };
 
-class wxStringInternalBufferLength : public wxStringTypeBufferLengthBase<wxStringCharType>
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(
+    wxStringTypeBufferLengthBase<wxStringCharType> )
+
+class wxStringInternalBufferLength
+    : public wxStringTypeBufferLengthBase<wxStringCharType>
 {
 public:
     wxStringInternalBufferLength(wxString& str, size_t lenWanted = 1024)
@@ -2874,6 +2881,9 @@ typedef wxStringInternalBufferLength          wxStringBufferLength;
 typedef wxStringInternalBuffer                wxUTF8StringBuffer;
 typedef wxStringInternalBufferLength          wxUTF8StringBufferLength;
 #elif wxUSE_UNICODE_WCHAR
+
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferBase<char> )
+
 class WXDLLIMPEXP_BASE wxUTF8StringBuffer : public wxStringTypeBufferBase<char>
 {
 public:
@@ -2884,6 +2894,8 @@ public:
     DECLARE_NO_COPY_CLASS(wxUTF8StringBuffer)
 };
 
+WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxStringTypeBufferLengthBase<char> )
+
 class WXDLLIMPEXP_BASE wxUTF8StringBufferLength
     : public wxStringTypeBufferLengthBase<char>
 {