From 6cf2fb76fe35e84852cec2517703d9d5e068b4a8 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 25 Sep 2005 18:09:26 +0000
Subject: [PATCH] added wxFORCE_LINK_MODULE public macro which can now be used
 outside of wxHTML too; modified it to not provoke icc warnings when used

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35684 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 build/bakefiles/files.bkl  |  1 +
 include/wx/html/forcelnk.h | 19 +++----------------
 include/wx/link.h          | 32 ++++++++++++++++++++++++++++++++
 src/common/archive.cpp     |  6 ++----
 src/common/zipstrm.cpp     | 12 ++++--------
 5 files changed, 42 insertions(+), 28 deletions(-)
 create mode 100644 include/wx/link.h

diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl
index 654d2058af..372adc9c8c 100644
--- a/build/bakefiles/files.bkl
+++ b/build/bakefiles/files.bkl
@@ -392,6 +392,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/ipcbase.h
     wx/isql.h
     wx/isqlext.h
+    wx/link.h
     wx/list.h
     wx/listimpl.cpp
     wx/log.h
diff --git a/include/wx/html/forcelnk.h b/include/wx/html/forcelnk.h
index 42cb66f95f..9b1373784f 100644
--- a/include/wx/html/forcelnk.h
+++ b/include/wx/html/forcelnk.h
@@ -40,22 +40,9 @@ See mod_*.cpp and htmlwin.cpp for example :-)
 #ifndef _WX_FORCELNK_H_
 #define _WX_FORCELNK_H_
 
-
-
-// This must be part of the module you want to force:
-#define FORCE_LINK_ME(module_name)                                    \
-                int _wx_link_dummy_func_##module_name ();             \
-                int _wx_link_dummy_func_##module_name ()              \
-                {                                                     \
-                    return 1;                                         \
-                }
-
-
-// And this must be somewhere where it certainly will be linked:
-#define FORCE_LINK(module_name)                                       \
-                extern int _wx_link_dummy_func_##module_name ();      \
-                static int _wx_link_dummy_var_##module_name =         \
-                               _wx_link_dummy_func_##module_name ();
+// compatibility defines
+#define FORCE_LINK wxFORCE_LINK_MODULE
+#define FORCE_LINK_ME wxFORCE_LINK_THIS_MODULE
 
 #define FORCE_WXHTML_MODULES() \
     FORCE_LINK(m_layout) \
diff --git a/include/wx/link.h b/include/wx/link.h
new file mode 100644
index 0000000000..0d1a4eb337
--- /dev/null
+++ b/include/wx/link.h
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/link.h
+// Purpose:     macros to force linking modules which might otherwise be
+//              discarded by the linker
+// Author:      Vaclav Slavik
+// RCS-ID:      $Id$
+// Copyright:   (c) Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_LINK_H_
+#define _WX_LINK_H_
+
+// This must be part of the module you want to force:
+#define wxFORCE_LINK_THIS_MODULE(module_name)                         \
+                extern void _wx_link_dummy_func_##module_name ();     \
+                void _wx_link_dummy_func_##module_name () { }
+
+
+// And this must be somewhere where it certainly will be linked:
+#define wxFORCE_LINK_MODULE(module_name)                              \
+                extern int _wx_link_dummy_func_##module_name ();      \
+                static struct wxForceLink##module_name                \
+                {                                                     \
+                    wxForceLink##module_name()                        \
+                    {                                                 \
+                        _wx_link_dummy_func_##module_name ();         \
+                    }                                                 \
+                } _wx_link_dummy_var_##module_name;
+
+
+#endif // _WX_LINK_H_
diff --git a/src/common/archive.cpp b/src/common/archive.cpp
index 223b8942bb..757425b277 100644
--- a/src/common/archive.cpp
+++ b/src/common/archive.cpp
@@ -21,15 +21,13 @@
 #if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
 
 #include "wx/archive.h"
+#include "wx/link.h"
 
 IMPLEMENT_ABSTRACT_CLASS(wxArchiveEntry, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxObject)
 
 #if wxUSE_ZIPSTREAM
-//FORCE_LINK(zipstrm)
-extern int _wx_link_dummy_func_zipstrm();
-static int _wx_link_dummy_var_zipstrm =
-               _wx_link_dummy_func_zipstrm ();
+wxFORCE_LINK_MODULE(zipstrm)
 #endif
 
 
diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp
index 273393f8f2..a2e12cc38b 100644
--- a/src/common/zipstrm.cpp
+++ b/src/common/zipstrm.cpp
@@ -30,6 +30,7 @@
 #include "wx/buffer.h"
 #include "wx/ptr_scpd.h"
 #include "wx/wfstream.h"
+#include "wx/link.h"
 #include "zlib.h"
 
 // value for the 'version needed to extract' field (20 means 2.0)
@@ -77,12 +78,7 @@ enum {
 IMPLEMENT_DYNAMIC_CLASS(wxZipEntry, wxArchiveEntry)
 IMPLEMENT_DYNAMIC_CLASS(wxZipClassFactory, wxArchiveClassFactory)
 
-//FORCE_LINK_ME(zipstrm)
-int _wx_link_dummy_func_zipstrm();
-int _wx_link_dummy_func_zipstrm()
-{
-    return 1;
-}
+wxFORCE_LINK_THIS_MODULE(zipstrm)
 
 
 /////////////////////////////////////////////////////////////////////////////
@@ -168,7 +164,7 @@ wxStoredInputStream::wxStoredInputStream(wxInputStream& stream)
 
 size_t wxStoredInputStream::OnSysRead(void *buffer, size_t size)
 {
-    size_t count = wxMin(size, (size_t)(m_len - m_pos));
+    size_t count = wxMin(size, wx_truncate_cast(size_t, m_len - m_pos));
     count = m_parent_i_stream->Read(buffer, count).LastRead();
     m_pos += count;
 
@@ -1820,7 +1816,7 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
 // Output stream
 
 #include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wx__ZipEntryList);
+WX_DEFINE_LIST(wx__ZipEntryList)
 
 wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
                                      int level      /*=-1*/,
-- 
2.47.2