]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/dlimpexp.h
3 * Purpose: Macros for declaring DLL-imported/exported functions
4 * Author: Vadim Zeitlin
6 * Created: 16.10.2003 (extracted from wx/defs.h)
8 * Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 * Licence: wxWindows licence
13 This is a C file, not C++ one, do not use C++ comments here!
16 #ifndef _WX_DLIMPEXP_H_
17 #define _WX_DLIMPEXP_H_
19 #if defined(HAVE_VISIBILITY)
20 # define WXEXPORT __attribute__ ((visibility("default")))
21 # define WXIMPORT __attribute__ ((visibility("default")))
22 #elif defined(__WINDOWS__)
24 __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
27 # if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__)
28 # define WXEXPORT __declspec(dllexport)
29 # define WXIMPORT __declspec(dllimport)
30 # else /* compiler doesn't support __declspec() */
34 #elif defined(__WXPM__)
35 # if defined (__WATCOMC__)
36 # define WXEXPORT __declspec(dllexport)
38 __declspec(dllimport) prepends __imp to imported symbols. We do NOT
42 # elif defined(__EMX__)
45 # elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
46 # define WXEXPORT _Export
47 # define WXIMPORT _Export
49 #elif defined(__WXMAC__) || defined(__WXCOCOA__)
51 # define WXEXPORT __declspec(export)
52 # define WXIMPORT __declspec(import)
54 #elif defined(__CYGWIN__)
55 # define WXEXPORT __declspec(dllexport)
56 # define WXIMPORT __declspec(dllimport)
59 /* for other platforms/compilers we don't anything */
66 We support building wxWidgets as a set of several libraries but we don't
67 support arbitrary combinations of libs/DLLs: either we build all of them as
68 DLLs (in which case WXMAKINGDLL is defined) or none (it isn't).
70 However we have a problem because we need separate WXDLLIMPEXP versions for
71 different libraries as, for example, wxString class should be dllexported
72 when compiled in wxBase and dllimported otherwise, so we do define separate
73 WXMAKING/USINGDLL_XYZ constants for each component XYZ.
77 # define WXMAKINGDLL_BASE
80 # define WXMAKINGDLL_NET
81 # define WXMAKINGDLL_CORE
82 # define WXMAKINGDLL_ADV
83 # define WXMAKINGDLL_QA
84 # define WXMAKINGDLL_HTML
85 # define WXMAKINGDLL_GL
86 # define WXMAKINGDLL_XML
87 # define WXMAKINGDLL_XRC
88 # define WXMAKINGDLL_AUI
89 # define WXMAKINGDLL_RICHTEXT
90 # define WXMAKINGDLL_MEDIA
91 # define WXMAKINGDLL_STC
92 #endif /* WXMAKINGDLL */
95 WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import
96 declaration if using it or to nothing at all if we don't use wxWin as DLL
98 #ifdef WXMAKINGDLL_BASE
99 # define WXDLLIMPEXP_BASE WXEXPORT
100 # define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type
101 # if defined(HAVE_VISIBILITY)
102 # define WXDLLIMPEXP_INLINE_BASE WXEXPORT
104 # define WXDLLIMPEXP_INLINE_BASE
106 #elif defined(WXUSINGDLL)
107 # define WXDLLIMPEXP_BASE WXIMPORT
108 # define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type
109 # if defined(HAVE_VISIBILITY)
110 # define WXDLLIMPEXP_INLINE_BASE WXIMPORT
112 # define WXDLLIMPEXP_INLINE_BASE
114 #else /* not making nor using DLL */
115 # define WXDLLIMPEXP_BASE
116 # define WXDLLIMPEXP_DATA_BASE(type) type
117 # define WXDLLIMPEXP_INLINE_BASE
120 #ifdef WXMAKINGDLL_NET
121 # define WXDLLIMPEXP_NET WXEXPORT
122 # define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type
123 #elif defined(WXUSINGDLL)
124 # define WXDLLIMPEXP_NET WXIMPORT
125 # define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type
126 #else /* not making nor using DLL */
127 # define WXDLLIMPEXP_NET
128 # define WXDLLIMPEXP_DATA_NET(type) type
131 #ifdef WXMAKINGDLL_CORE
132 # define WXDLLIMPEXP_CORE WXEXPORT
133 # define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type
134 #elif defined(WXUSINGDLL)
135 # define WXDLLIMPEXP_CORE WXIMPORT
136 # define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
137 #else /* not making nor using DLL */
138 # define WXDLLIMPEXP_CORE
139 # define WXDLLIMPEXP_DATA_CORE(type) type
142 #ifdef WXMAKINGDLL_ADV
143 # define WXDLLIMPEXP_ADV WXEXPORT
144 # define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type
145 #elif defined(WXUSINGDLL)
146 # define WXDLLIMPEXP_ADV WXIMPORT
147 # define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type
148 #else /* not making nor using DLL */
149 # define WXDLLIMPEXP_ADV
150 # define WXDLLIMPEXP_DATA_ADV(type) type
153 #ifdef WXMAKINGDLL_QA
154 # define WXDLLIMPEXP_QA WXEXPORT
155 # define WXDLLIMPEXP_DATA_QA(type) WXEXPORT type
156 #elif defined(WXUSINGDLL)
157 # define WXDLLIMPEXP_QA WXIMPORT
158 # define WXDLLIMPEXP_DATA_QA(type) WXIMPORT type
159 #else /* not making nor using DLL */
160 # define WXDLLIMPEXP_QA
161 # define WXDLLIMPEXP_DATA_QA(type) type
164 #ifdef WXMAKINGDLL_HTML
165 # define WXDLLIMPEXP_HTML WXEXPORT
166 # define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type
167 #elif defined(WXUSINGDLL)
168 # define WXDLLIMPEXP_HTML WXIMPORT
169 # define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type
170 #else /* not making nor using DLL */
171 # define WXDLLIMPEXP_HTML
172 # define WXDLLIMPEXP_DATA_HTML(type) type
175 #ifdef WXMAKINGDLL_GL
176 # define WXDLLIMPEXP_GL WXEXPORT
177 #elif defined(WXUSINGDLL)
178 # define WXDLLIMPEXP_GL WXIMPORT
179 #else /* not making nor using DLL */
180 # define WXDLLIMPEXP_GL
183 #ifdef WXMAKINGDLL_XML
184 # define WXDLLIMPEXP_XML WXEXPORT
185 #elif defined(WXUSINGDLL)
186 # define WXDLLIMPEXP_XML WXIMPORT
187 #else /* not making nor using DLL */
188 # define WXDLLIMPEXP_XML
191 #ifdef WXMAKINGDLL_XRC
192 # define WXDLLIMPEXP_XRC WXEXPORT
193 #elif defined(WXUSINGDLL)
194 # define WXDLLIMPEXP_XRC WXIMPORT
195 #else /* not making nor using DLL */
196 # define WXDLLIMPEXP_XRC
199 #ifdef WXMAKINGDLL_AUI
200 # define WXDLLIMPEXP_AUI WXEXPORT
201 #elif defined(WXUSINGDLL)
202 # define WXDLLIMPEXP_AUI WXIMPORT
203 #else /* not making nor using DLL */
204 # define WXDLLIMPEXP_AUI
207 #ifdef WXMAKINGDLL_PROPGRID
208 # define WXDLLIMPEXP_PROPGRID WXEXPORT
209 #elif defined(WXUSINGDLL)
210 # define WXDLLIMPEXP_PROPGRID WXIMPORT
211 #else /* not making nor using DLL */
212 # define WXDLLIMPEXP_PROPGRID
215 #ifdef WXMAKINGDLL_RICHTEXT
216 # define WXDLLIMPEXP_RICHTEXT WXEXPORT
217 #elif defined(WXUSINGDLL)
218 # define WXDLLIMPEXP_RICHTEXT WXIMPORT
219 #else /* not making nor using DLL */
220 # define WXDLLIMPEXP_RICHTEXT
223 #ifdef WXMAKINGDLL_MEDIA
224 # define WXDLLIMPEXP_MEDIA WXEXPORT
225 #elif defined(WXUSINGDLL)
226 # define WXDLLIMPEXP_MEDIA WXIMPORT
227 #else /* not making nor using DLL */
228 # define WXDLLIMPEXP_MEDIA
231 #ifdef WXMAKINGDLL_STC
232 #define WXDLLIMPEXP_STC WXEXPORT
233 #elif defined(WXUSINGDLL)
234 #define WXDLLIMPEXP_STC WXIMPORT
235 #else /* not making nor using DLL */
236 #define WXDLLIMPEXP_STC
240 GCC warns about using __attribute__ (and also __declspec in mingw32 case) on
241 forward declarations while MSVC complains about forward declarations without
242 __declspec for the classes later declared with it, so we need a separate set
243 of macros for forward declarations to hide this difference:
245 #if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__))
246 #define WXDLLIMPEXP_FWD_BASE
247 #define WXDLLIMPEXP_FWD_NET
248 #define WXDLLIMPEXP_FWD_CORE
249 #define WXDLLIMPEXP_FWD_ADV
250 #define WXDLLIMPEXP_FWD_QA
251 #define WXDLLIMPEXP_FWD_HTML
252 #define WXDLLIMPEXP_FWD_GL
253 #define WXDLLIMPEXP_FWD_XML
254 #define WXDLLIMPEXP_FWD_XRC
255 #define WXDLLIMPEXP_FWD_AUI
256 #define WXDLLIMPEXP_FWD_RICHTEXT
257 #define WXDLLIMPEXP_FWD_MEDIA
258 #define WXDLLIMPEXP_FWD_STC
260 #define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE
261 #define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET
262 #define WXDLLIMPEXP_FWD_CORE WXDLLIMPEXP_CORE
263 #define WXDLLIMPEXP_FWD_ADV WXDLLIMPEXP_ADV
264 #define WXDLLIMPEXP_FWD_QA WXDLLIMPEXP_QA
265 #define WXDLLIMPEXP_FWD_HTML WXDLLIMPEXP_HTML
266 #define WXDLLIMPEXP_FWD_GL WXDLLIMPEXP_GL
267 #define WXDLLIMPEXP_FWD_XML WXDLLIMPEXP_XML
268 #define WXDLLIMPEXP_FWD_XRC WXDLLIMPEXP_XRC
269 #define WXDLLIMPEXP_FWD_AUI WXDLLIMPEXP_AUI
270 #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT
271 #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA
272 #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC
275 /* for backwards compatibility, define suffix-less versions too */
276 #define WXDLLEXPORT WXDLLIMPEXP_CORE
277 #define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE
280 MSVC up to 6.0 needs to be explicitly told to export template instantiations
281 used by the DLL clients, use this macro to do it like this:
283 template <typename T> class Foo { ... };
284 WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> )
286 (notice that currently we only need this for wxBase and wxCore libraries)
288 #if defined(__VISUALC__) && (__VISUALC__ <= 1200)
289 #ifdef WXMAKINGDLL_BASE
290 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
291 template class WXDLLIMPEXP_BASE decl;
292 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
293 template class WXDLLIMPEXP_CORE decl;
296 We need to disable this warning when using this macro, as
297 recommended by Microsoft itself:
299 http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958
301 #pragma warning(disable:4231)
303 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
304 extern template class WXDLLIMPEXP_BASE decl;
305 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
306 extern template class WXDLLIMPEXP_CORE decl;
308 #else /* not VC <= 6 */
309 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
310 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl)
311 #endif /* VC6/others */
313 #endif /* _WX_DLIMPEXP_H_ */