From: Vadim Zeitlin Date: Thu, 16 Oct 2003 10:25:56 +0000 (+0000) Subject: moved DLL import/export declarations from wx/defs.h to (new) wx/dlimpexp.h for GSocke... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/0cc66b6c0b7b50bfba244e4f8e48a9b071e75ae2 moved DLL import/export declarations from wx/defs.h to (new) wx/dlimpexp.h for GSocket; added wxUnusedVar() and wxDUMMY_INITIALIZE() to wx/defs.h git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 9c4988d62f..8f42fbf70e 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -217,6 +217,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/debug.h wx/defs.h wx/dir.h + wx/dlimpexp.h wx/dynarray.h wx/dynlib.h wx/dynload.h diff --git a/include/wx/defs.h b/include/wx/defs.h index 1309723ae5..f1fe077816 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -16,6 +16,10 @@ #pragma interface "defs.h" #endif +#ifndef __cplusplus + #error "This header is for C++ code only" +#endif + // ---------------------------------------------------------------------------- // compiler and OS identification // ---------------------------------------------------------------------------- @@ -350,165 +354,8 @@ typedef int wxWindowID; // compatibility :-( #define CMPFUNC_CONV wxCMPFUNC_CONV -// ---------------------------------------------------------------------------- -// Making or using wxWindows as a Windows DLL -// ---------------------------------------------------------------------------- - -#if defined(__WXMSW__) - // __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well - // as VC++ and gcc - #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__) - #define WXEXPORT __declspec(dllexport) - #define WXIMPORT __declspec(dllimport) - #else // compiler doesn't support __declspec() - #define WXEXPORT - #define WXIMPORT - #endif -#elif defined(__WXPM__) - #if defined (__WATCOMC__) - #define WXEXPORT __declspec(dllexport) - // __declspec(dllimport) prepends __imp to imported symbols. We do NOT - // want that! - #define WXIMPORT - #elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 ))) - #define WXEXPORT _Export - #define WXIMPORT _Export - #endif -#elif defined(__WXMAC__) || defined(__WXCOCOA__) - #ifdef __MWERKS__ - #define WXEXPORT __declspec(export) - #define WXIMPORT __declspec(import) - #endif -#endif - -// for other platforms/compilers we don't anything -#ifndef WXEXPORT - #define WXEXPORT - #define WXIMPORT -#endif - -/* - We support building wxWindows as a set of several libraries but we don't - support arbitrary combinations of libs/DLLs: either we build all of them as - DLLs (in which case WXMAKINGDLL is defined) or none (it isn't). - - However we have a problem because we need separate WXDLLEXPORT versions for - different libraries as, for example, wxString class should be dllexported - when compiled in wxBase and dllimported otherwise, so we do define separate - WXMAKING/USINGDLL_XYZ constants for each component XYZ. - */ -#ifdef WXMAKINGDLL - #if wxUSE_BASE - #define WXMAKINGDLL_BASE - #endif - - #define WXMAKINGDLL_NET - #define WXMAKINGDLL_CORE - #define WXMAKINGDLL_ADV - #define WXMAKINGDLL_ODBC - #define WXMAKINGDLL_DBGRID - #define WXMAKINGDLL_HTML - #define WXMAKINGDLL_XML -#endif // WXMAKINGDLL - -// WXDLLEXPORT maps to export declaration when building the DLL, to import -// declaration if using it or to nothing at all if we don't use wxWin as DLL -#ifdef WXMAKINGDLL_BASE - #define WXDLLIMPEXP_BASE WXEXPORT - #define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_BASE WXIMPORT - #define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_BASE - #define WXDLLIMPEXP_DATA_BASE(type) type -#endif - -#ifdef WXMAKINGDLL_NET - #define WXDLLIMPEXP_NET WXEXPORT - #define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_NET WXIMPORT - #define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_NET - #define WXDLLIMPEXP_DATA_NET(type) type -#endif - -#ifdef WXMAKINGDLL_CORE - #define WXDLLIMPEXP_CORE WXEXPORT - #define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_CORE WXIMPORT - #define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_CORE - #define WXDLLIMPEXP_DATA_CORE(type) type -#endif - -#ifdef WXMAKINGDLL_ADV - #define WXDLLIMPEXP_ADV WXEXPORT - #define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_ADV WXIMPORT - #define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_ADV - #define WXDLLIMPEXP_DATA_ADV(type) type -#endif - -#ifdef WXMAKINGDLL_ODBC - #define WXDLLIMPEXP_ODBC WXEXPORT - #define WXDLLIMPEXP_DATA_ODBC(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_ODBC WXIMPORT - #define WXDLLIMPEXP_DATA_ODBC(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_ODBC - #define WXDLLIMPEXP_DATA_ODBC(type) type -#endif - -#ifdef WXMAKINGDLL_DBGRID - #define WXDLLIMPEXP_DBGRID WXEXPORT - #define WXDLLIMPEXP_DATA_DBGRID(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_DBGRID WXIMPORT - #define WXDLLIMPEXP_DATA_DBGRID(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_DBGRID - #define WXDLLIMPEXP_DATA_DBGRID(type) type -#endif - -#ifdef WXMAKINGDLL_HTML - #define WXDLLIMPEXP_HTML WXEXPORT - #define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_HTML WXIMPORT - #define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type -#else // not making nor using DLL - #define WXDLLIMPEXP_HTML - #define WXDLLIMPEXP_DATA_HTML(type) type -#endif - -#ifdef WXMAKINGDLL_GL - #define WXDLLIMPEXP_GL WXEXPORT -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_GL WXIMPORT -#else // not making nor using DLL - #define WXDLLIMPEXP_GL -#endif - -#ifdef WXMAKINGDLL_XML - #define WXDLLIMPEXP_XML WXEXPORT -#elif defined(WXUSINGDLL) - #define WXDLLIMPEXP_XML WXIMPORT -#else // not making nor using DLL - #define WXDLLIMPEXP_XML -#endif - -// for backwards compatibility, define suffix-less versions too -#define WXDLLEXPORT WXDLLIMPEXP_CORE -#define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE +// DLL import/export declarations +#include "wx/dlimpexp.h" // ---------------------------------------------------------------------------- // Very common macros @@ -545,29 +392,13 @@ typedef int wxWindowID; #endif // everybody gets the assert and other debug macros -#ifdef __cplusplus #include "wx/debug.h" -#endif // NULL declaration: it must be defined as 0 for C++ programs (in particular, // it must not be defined as "(void *)0" which is standard for C but completely // breaks C++ code) #include -// Macro to cut down on compiler warnings. -#if REMOVE_UNUSED_ARG - #define WXUNUSED(identifier) /* identifier */ -#else // stupid, broken compiler - #define WXUNUSED(identifier) identifier -#endif - -// some arguments are only used in debug mode, but unused in release one -#ifdef __WXDEBUG__ - #define WXUNUSED_UNLESS_DEBUG(param) param -#else - #define WXUNUSED_UNLESS_DEBUG(param) WXUNUSED(param) -#endif - // delete pointer if it is not NULL and NULL it afterwards // (checking that it's !NULL before passing it to delete is just a // a question of style, because delete will do it itself anyhow, but it might @@ -596,6 +427,39 @@ typedef int wxWindowID; // integer on success as failure indicator #define wxNOT_FOUND (-1) +// ---------------------------------------------------------------------------- +// macros to avoid compiler warnings +// ---------------------------------------------------------------------------- + +// Macro to cut down on compiler warnings. +#if 1 // there should be no more any compilers needing the "#else" version + #define WXUNUSED(identifier) /* identifier */ +#else // stupid, broken compiler + #define WXUNUSED(identifier) identifier +#endif + +// some arguments are only used in debug mode, but unused in release one +#ifdef __WXDEBUG__ + #define WXUNUSED_UNLESS_DEBUG(param) param +#else + #define WXUNUSED_UNLESS_DEBUG(param) WXUNUSED(param) +#endif + +// some compilers give warning about a possibly unused variable if it is +// initialized in both branches of if/else and shut up if it is initialized +// when declared, but other compilers then give warnings about unused variable +// value -- this should satisfy both of them +#if defined(__VISUALC__) + #define wxDUMMY_INITIALIZE(val) = val +#else + #define wxDUMMY_INITIALIZE(val) +#endif + +// sometimes the value of a variable is *really* not used, to suppress the +// resulting warning you may pass it to this function +template +inline void wxUnusedVar(const T& WXUNUSED(t)) { } + // ---------------------------------------------------------------------------- // compiler specific settings // ---------------------------------------------------------------------------- diff --git a/include/wx/dlimpexp.h b/include/wx/dlimpexp.h new file mode 100644 index 0000000000..cc892158e1 --- /dev/null +++ b/include/wx/dlimpexp.h @@ -0,0 +1,182 @@ +/* + * Name: wx/dlimpexp.h + * Purpose: Macros for declaring DLL-imported/exported functions + * Author: Vadim Zeitlin + * Modified by: + * Created: 16.10.2003 (extracted from wx/defs.h) + * RCS-ID: $Id$ + * Copyright: (c) 2003 Vadim Zeitlin + * Licence: wxWindows licence + */ + +/* + This is a C file, not C++ one, do not use C++ comments here! + */ + +#ifndef _WX_DLIMPEXP_H_ +#define _WX_DLIMPEXP_H_ + +#if defined(__WXMSW__) + /* + __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well + as VC++ and gcc + */ +# if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__) +# define WXEXPORT __declspec(dllexport) +# define WXIMPORT __declspec(dllimport) +# else /* compiler doesn't support __declspec() */ +# define WXEXPORT +# define WXIMPORT +# endif +#elif defined(__WXPM__) +# if defined (__WATCOMC__) +# define WXEXPORT __declspec(dllexport) + /* + __declspec(dllimport) prepends __imp to imported symbols. We do NOT + want that! + */ +# define WXIMPORT +# elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 ))) +# define WXEXPORT _Export +# define WXIMPORT _Export +# endif +#elif defined(__WXMAC__) || defined(__WXCOCOA__) +# ifdef __MWERKS__ +# define WXEXPORT __declspec(export) +# define WXIMPORT __declspec(import) +# endif +#endif + +/* for other platforms/compilers we don't anything */ +#ifndef WXEXPORT +# define WXEXPORT +# define WXIMPORT +#endif + +/* + We support building wxWindows as a set of several libraries but we don't + support arbitrary combinations of libs/DLLs: either we build all of them as + DLLs (in which case WXMAKINGDLL is defined) or none (it isn't). + + However we have a problem because we need separate WXDLLEXPORT versions for + different libraries as, for example, wxString class should be dllexported + when compiled in wxBase and dllimported otherwise, so we do define separate + WXMAKING/USINGDLL_XYZ constants for each component XYZ. + */ +#ifdef WXMAKINGDLL +# if wxUSE_BASE +# define WXMAKINGDLL_BASE +# endif + +# define WXMAKINGDLL_NET +# define WXMAKINGDLL_CORE +# define WXMAKINGDLL_ADV +# define WXMAKINGDLL_ODBC +# define WXMAKINGDLL_DBGRID +# define WXMAKINGDLL_HTML +# define WXMAKINGDLL_XML +#endif /* WXMAKINGDLL */ + +/* + WXDLLEXPORT maps to export declaration when building the DLL, to import + declaration if using it or to nothing at all if we don't use wxWin as DLL + */ +#ifdef WXMAKINGDLL_BASE +# define WXDLLIMPEXP_BASE WXEXPORT +# define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_BASE WXIMPORT +# define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_BASE +# define WXDLLIMPEXP_DATA_BASE(type) type +#endif + +#ifdef WXMAKINGDLL_NET +# define WXDLLIMPEXP_NET WXEXPORT +# define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_NET WXIMPORT +# define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_NET +# define WXDLLIMPEXP_DATA_NET(type) type +#endif + +#ifdef WXMAKINGDLL_CORE +# define WXDLLIMPEXP_CORE WXEXPORT +# define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_CORE WXIMPORT +# define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_CORE +# define WXDLLIMPEXP_DATA_CORE(type) type +#endif + +#ifdef WXMAKINGDLL_ADV +# define WXDLLIMPEXP_ADV WXEXPORT +# define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_ADV WXIMPORT +# define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_ADV +# define WXDLLIMPEXP_DATA_ADV(type) type +#endif + +#ifdef WXMAKINGDLL_ODBC +# define WXDLLIMPEXP_ODBC WXEXPORT +# define WXDLLIMPEXP_DATA_ODBC(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_ODBC WXIMPORT +# define WXDLLIMPEXP_DATA_ODBC(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_ODBC +# define WXDLLIMPEXP_DATA_ODBC(type) type +#endif + +#ifdef WXMAKINGDLL_DBGRID +# define WXDLLIMPEXP_DBGRID WXEXPORT +# define WXDLLIMPEXP_DATA_DBGRID(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_DBGRID WXIMPORT +# define WXDLLIMPEXP_DATA_DBGRID(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_DBGRID +# define WXDLLIMPEXP_DATA_DBGRID(type) type +#endif + +#ifdef WXMAKINGDLL_HTML +# define WXDLLIMPEXP_HTML WXEXPORT +# define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_HTML WXIMPORT +# define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_HTML +# define WXDLLIMPEXP_DATA_HTML(type) type +#endif + +#ifdef WXMAKINGDLL_GL +# define WXDLLIMPEXP_GL WXEXPORT +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_GL WXIMPORT +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_GL +#endif + +#ifdef WXMAKINGDLL_XML +# define WXDLLIMPEXP_XML WXEXPORT +#elif defined(WXUSINGDLL) +# define WXDLLIMPEXP_XML WXIMPORT +#else /* not making nor using DLL */ +# define WXDLLIMPEXP_XML +#endif + +/* for backwards compatibility, define suffix-less versions too */ +#define WXDLLEXPORT WXDLLIMPEXP_CORE +#define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE + +#endif /* _WX_DLIMPEXP_H_ */ + diff --git a/include/wx/gsocket.h b/include/wx/gsocket.h index 2b626a698e..6070b76de8 100644 --- a/include/wx/gsocket.h +++ b/include/wx/gsocket.h @@ -14,12 +14,7 @@ #ifndef __GSOCKET_STANDALONE__ #include "wx/setup.h" -/* kludge for GTK.. gsockgtk.c craps out miserably if we include - defs.h ... no idea how other files get away with it.. */ - -#if !defined( __WXMSW__ ) && !defined( WXDLLIMPEXP_NET ) -#define WXDLLIMPEXP_NET -#endif +#include "wx/dlimpexp.h" // for WXDLLIMPEXP_NET #endif diff --git a/src/msw/gsockmsw.c b/src/msw/gsockmsw.c index bcf257a608..4827241cff 100644 --- a/src/msw/gsockmsw.c +++ b/src/msw/gsockmsw.c @@ -36,7 +36,6 @@ #endif #ifndef __GSOCKET_STANDALONE__ -#include "wx/defs.h" #include "wx/setup.h" #endif