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
This commit is contained in:
Vadim Zeitlin 2005-09-25 18:09:26 +00:00
parent 7a7bd38a77
commit 6cf2fb76fe
5 changed files with 42 additions and 28 deletions

View File

@ -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

View File

@ -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) \

32
include/wx/link.h Normal file
View File

@ -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_

View File

@ -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

View File

@ -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*/,