]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dlimpexp.h
Make wxRect parameter of wxRichToolTip::ShowFor() const.
[wxWidgets.git] / include / wx / dlimpexp.h
1 /*
2 * Name: wx/dlimpexp.h
3 * Purpose: Macros for declaring DLL-imported/exported functions
4 * Author: Vadim Zeitlin
5 * Modified by:
6 * Created: 16.10.2003 (extracted from wx/defs.h)
7 * RCS-ID: $Id$
8 * Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 * Licence: wxWindows licence
10 */
11
12 /*
13 This is a C file, not C++ one, do not use C++ comments here!
14 */
15
16 #ifndef _WX_DLIMPEXP_H_
17 #define _WX_DLIMPEXP_H_
18
19 #if defined(HAVE_VISIBILITY)
20 # define WXEXPORT __attribute__ ((visibility("default")))
21 # define WXIMPORT __attribute__ ((visibility("default")))
22 #elif defined(__WINDOWS__)
23 /*
24 __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
25 as VC++.
26 */
27 # if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
28 # define WXEXPORT __declspec(dllexport)
29 # define WXIMPORT __declspec(dllimport)
30 /*
31 While gcc also supports __declspec(dllexport), it creates unusably huge
32 DLL files since gcc 4.5 (while taking horribly long amounts of time),
33 see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601. Because of this
34 we rely on binutils auto export/import support which seems to work
35 quite well for 4.5+.
36 */
37 # elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5)
38 /*
39 __declspec could be used here too but let's use the native
40 __attribute__ instead for clarity.
41 */
42 # define WXEXPORT __attribute__((dllexport))
43 # define WXIMPORT __attribute__((dllimport))
44 # endif
45 #elif defined(__WXPM__)
46 # if defined (__WATCOMC__)
47 # define WXEXPORT __declspec(dllexport)
48 /*
49 __declspec(dllimport) prepends __imp to imported symbols. We do NOT
50 want that!
51 */
52 # define WXIMPORT
53 # elif defined(__EMX__)
54 # define WXEXPORT
55 # define WXIMPORT
56 # elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
57 # define WXEXPORT _Export
58 # define WXIMPORT _Export
59 # endif
60 #elif defined(__CYGWIN__)
61 # define WXEXPORT __declspec(dllexport)
62 # define WXIMPORT __declspec(dllimport)
63 #endif
64
65 /* for other platforms/compilers we don't anything */
66 #ifndef WXEXPORT
67 # define WXEXPORT
68 # define WXIMPORT
69 #endif
70
71 /*
72 We support building wxWidgets as a set of several libraries but we don't
73 support arbitrary combinations of libs/DLLs: either we build all of them as
74 DLLs (in which case WXMAKINGDLL is defined) or none (it isn't).
75
76 However we have a problem because we need separate WXDLLIMPEXP versions for
77 different libraries as, for example, wxString class should be dllexported
78 when compiled in wxBase and dllimported otherwise, so we do define separate
79 WXMAKING/USINGDLL_XYZ constants for each component XYZ.
80 */
81 #ifdef WXMAKINGDLL
82 # if wxUSE_BASE
83 # define WXMAKINGDLL_BASE
84 # endif
85
86 # define WXMAKINGDLL_NET
87 # define WXMAKINGDLL_CORE
88 # define WXMAKINGDLL_ADV
89 # define WXMAKINGDLL_QA
90 # define WXMAKINGDLL_HTML
91 # define WXMAKINGDLL_GL
92 # define WXMAKINGDLL_XML
93 # define WXMAKINGDLL_XRC
94 # define WXMAKINGDLL_AUI
95 # define WXMAKINGDLL_RIBBON
96 # define WXMAKINGDLL_PROPGRID
97 # define WXMAKINGDLL_RIBBON
98 # define WXMAKINGDLL_RICHTEXT
99 # define WXMAKINGDLL_MEDIA
100 # define WXMAKINGDLL_STC
101 # define WXMAKINGDLL_WEBVIEW
102 #endif /* WXMAKINGDLL */
103
104 /*
105 WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import
106 declaration if using it or to nothing at all if we don't use wxWin as DLL
107 */
108 #ifdef WXMAKINGDLL_BASE
109 # define WXDLLIMPEXP_BASE WXEXPORT
110 # define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type
111 # if defined(HAVE_VISIBILITY)
112 # define WXDLLIMPEXP_INLINE_BASE WXEXPORT
113 # else
114 # define WXDLLIMPEXP_INLINE_BASE
115 # endif
116 #elif defined(WXUSINGDLL)
117 # define WXDLLIMPEXP_BASE WXIMPORT
118 # define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type
119 # if defined(HAVE_VISIBILITY)
120 # define WXDLLIMPEXP_INLINE_BASE WXIMPORT
121 # else
122 # define WXDLLIMPEXP_INLINE_BASE
123 # endif
124 #else /* not making nor using DLL */
125 # define WXDLLIMPEXP_BASE
126 # define WXDLLIMPEXP_DATA_BASE(type) type
127 # define WXDLLIMPEXP_INLINE_BASE
128 #endif
129
130 #ifdef WXMAKINGDLL_NET
131 # define WXDLLIMPEXP_NET WXEXPORT
132 # define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type
133 #elif defined(WXUSINGDLL)
134 # define WXDLLIMPEXP_NET WXIMPORT
135 # define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type
136 #else /* not making nor using DLL */
137 # define WXDLLIMPEXP_NET
138 # define WXDLLIMPEXP_DATA_NET(type) type
139 #endif
140
141 #ifdef WXMAKINGDLL_CORE
142 # define WXDLLIMPEXP_CORE WXEXPORT
143 # define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type
144 # if defined(HAVE_VISIBILITY)
145 # define WXDLLIMPEXP_INLINE_CORE WXEXPORT
146 # else
147 # define WXDLLIMPEXP_INLINE_CORE
148 # endif
149 #elif defined(WXUSINGDLL)
150 # define WXDLLIMPEXP_CORE WXIMPORT
151 # define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
152 # if defined(HAVE_VISIBILITY)
153 # define WXDLLIMPEXP_INLINE_CORE WXIMPORT
154 # else
155 # define WXDLLIMPEXP_INLINE_CORE
156 # endif
157 #else /* not making nor using DLL */
158 # define WXDLLIMPEXP_CORE
159 # define WXDLLIMPEXP_DATA_CORE(type) type
160 # define WXDLLIMPEXP_INLINE_CORE
161 #endif
162
163 #ifdef WXMAKINGDLL_ADV
164 # define WXDLLIMPEXP_ADV WXEXPORT
165 # define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type
166 #elif defined(WXUSINGDLL)
167 # define WXDLLIMPEXP_ADV WXIMPORT
168 # define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type
169 #else /* not making nor using DLL */
170 # define WXDLLIMPEXP_ADV
171 # define WXDLLIMPEXP_DATA_ADV(type) type
172 #endif
173
174 #ifdef WXMAKINGDLL_QA
175 # define WXDLLIMPEXP_QA WXEXPORT
176 # define WXDLLIMPEXP_DATA_QA(type) WXEXPORT type
177 #elif defined(WXUSINGDLL)
178 # define WXDLLIMPEXP_QA WXIMPORT
179 # define WXDLLIMPEXP_DATA_QA(type) WXIMPORT type
180 #else /* not making nor using DLL */
181 # define WXDLLIMPEXP_QA
182 # define WXDLLIMPEXP_DATA_QA(type) type
183 #endif
184
185 #ifdef WXMAKINGDLL_HTML
186 # define WXDLLIMPEXP_HTML WXEXPORT
187 # define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type
188 #elif defined(WXUSINGDLL)
189 # define WXDLLIMPEXP_HTML WXIMPORT
190 # define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type
191 #else /* not making nor using DLL */
192 # define WXDLLIMPEXP_HTML
193 # define WXDLLIMPEXP_DATA_HTML(type) type
194 #endif
195
196 #ifdef WXMAKINGDLL_GL
197 # define WXDLLIMPEXP_GL WXEXPORT
198 #elif defined(WXUSINGDLL)
199 # define WXDLLIMPEXP_GL WXIMPORT
200 #else /* not making nor using DLL */
201 # define WXDLLIMPEXP_GL
202 #endif
203
204 #ifdef WXMAKINGDLL_XML
205 # define WXDLLIMPEXP_XML WXEXPORT
206 #elif defined(WXUSINGDLL)
207 # define WXDLLIMPEXP_XML WXIMPORT
208 #else /* not making nor using DLL */
209 # define WXDLLIMPEXP_XML
210 #endif
211
212 #ifdef WXMAKINGDLL_XRC
213 # define WXDLLIMPEXP_XRC WXEXPORT
214 #elif defined(WXUSINGDLL)
215 # define WXDLLIMPEXP_XRC WXIMPORT
216 #else /* not making nor using DLL */
217 # define WXDLLIMPEXP_XRC
218 #endif
219
220 #ifdef WXMAKINGDLL_AUI
221 # define WXDLLIMPEXP_AUI WXEXPORT
222 #elif defined(WXUSINGDLL)
223 # define WXDLLIMPEXP_AUI WXIMPORT
224 #else /* not making nor using DLL */
225 # define WXDLLIMPEXP_AUI
226 #endif
227
228 #ifdef WXMAKINGDLL_RIBBON
229 # define WXDLLIMPEXP_RIBBON WXEXPORT
230 #elif defined(WXUSINGDLL)
231 # define WXDLLIMPEXP_RIBBON WXIMPORT
232 #else /* not making nor using DLL */
233 # define WXDLLIMPEXP_RIBBON
234 #endif
235
236 #ifdef WXMAKINGDLL_PROPGRID
237 # define WXDLLIMPEXP_PROPGRID WXEXPORT
238 # define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type
239 #elif defined(WXUSINGDLL)
240 # define WXDLLIMPEXP_PROPGRID WXIMPORT
241 # define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type
242 #else /* not making nor using DLL */
243 # define WXDLLIMPEXP_PROPGRID
244 # define WXDLLIMPEXP_DATA_PROPGRID(type) type
245 #endif
246
247 #ifdef WXMAKINGDLL_RIBBON
248 # define WXDLLIMPEXP_RIBBON WXEXPORT
249 #elif defined(WXUSINGDLL)
250 # define WXDLLIMPEXP_RIBBON WXIMPORT
251 #else /* not making nor using DLL */
252 # define WXDLLIMPEXP_RIBBON
253 #endif
254
255 #ifdef WXMAKINGDLL_RICHTEXT
256 # define WXDLLIMPEXP_RICHTEXT WXEXPORT
257 #elif defined(WXUSINGDLL)
258 # define WXDLLIMPEXP_RICHTEXT WXIMPORT
259 #else /* not making nor using DLL */
260 # define WXDLLIMPEXP_RICHTEXT
261 #endif
262
263 #ifdef WXMAKINGDLL_MEDIA
264 # define WXDLLIMPEXP_MEDIA WXEXPORT
265 #elif defined(WXUSINGDLL)
266 # define WXDLLIMPEXP_MEDIA WXIMPORT
267 #else /* not making nor using DLL */
268 # define WXDLLIMPEXP_MEDIA
269 #endif
270
271 #ifdef WXMAKINGDLL_STC
272 # define WXDLLIMPEXP_STC WXEXPORT
273 # define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type
274 #elif defined(WXUSINGDLL)
275 # define WXDLLIMPEXP_STC WXIMPORT
276 # define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type
277 #else /* not making nor using DLL */
278 # define WXDLLIMPEXP_STC
279 # define WXDLLIMPEXP_DATA_STC(type) type
280 #endif
281
282 #ifdef WXMAKINGDLL_WEBVIEW
283 # define WXDLLIMPEXP_WEBVIEW WXEXPORT
284 # define WXDLLIMPEXP_DATA_WEBVIEW(type) WXEXPORT type
285 #elif defined(WXUSINGDLL)
286 # define WXDLLIMPEXP_WEBVIEW WXIMPORT
287 # define WXDLLIMPEXP_DATA_WEBVIEW(type) WXIMPORT type
288 #else /* not making nor using DLL */
289 # define WXDLLIMPEXP_WEBVIEW
290 # define WXDLLIMPEXP_DATA_WEBVIEW(type) type
291 #endif
292
293 /*
294 GCC warns about using __attribute__ (and also __declspec in mingw32 case) on
295 forward declarations while MSVC complains about forward declarations without
296 __declspec for the classes later declared with it, so we need a separate set
297 of macros for forward declarations to hide this difference:
298 */
299 #if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__))
300 #define WXDLLIMPEXP_FWD_BASE
301 #define WXDLLIMPEXP_FWD_NET
302 #define WXDLLIMPEXP_FWD_CORE
303 #define WXDLLIMPEXP_FWD_ADV
304 #define WXDLLIMPEXP_FWD_QA
305 #define WXDLLIMPEXP_FWD_HTML
306 #define WXDLLIMPEXP_FWD_GL
307 #define WXDLLIMPEXP_FWD_XML
308 #define WXDLLIMPEXP_FWD_XRC
309 #define WXDLLIMPEXP_FWD_AUI
310 #define WXDLLIMPEXP_FWD_PROPGRID
311 #define WXDLLIMPEXP_FWD_RIBBON
312 #define WXDLLIMPEXP_FWD_RICHTEXT
313 #define WXDLLIMPEXP_FWD_MEDIA
314 #define WXDLLIMPEXP_FWD_STC
315 #define WXDLLIMPEXP_FWD_WEBVIEW
316 #else
317 #define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE
318 #define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET
319 #define WXDLLIMPEXP_FWD_CORE WXDLLIMPEXP_CORE
320 #define WXDLLIMPEXP_FWD_ADV WXDLLIMPEXP_ADV
321 #define WXDLLIMPEXP_FWD_QA WXDLLIMPEXP_QA
322 #define WXDLLIMPEXP_FWD_HTML WXDLLIMPEXP_HTML
323 #define WXDLLIMPEXP_FWD_GL WXDLLIMPEXP_GL
324 #define WXDLLIMPEXP_FWD_XML WXDLLIMPEXP_XML
325 #define WXDLLIMPEXP_FWD_XRC WXDLLIMPEXP_XRC
326 #define WXDLLIMPEXP_FWD_AUI WXDLLIMPEXP_AUI
327 #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID
328 #define WXDLLIMPEXP_FWD_RIBBON WXDLLIMPEXP_RIBBON
329 #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT
330 #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA
331 #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC
332 #define WXDLLIMPEXP_FWD_WEBVIEW WXDLLIMPEXP_WEBVIEW
333 #endif
334
335 /* for backwards compatibility, define suffix-less versions too */
336 #define WXDLLEXPORT WXDLLIMPEXP_CORE
337 #define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE
338
339 /*
340 MSVC up to 6.0 needs to be explicitly told to export template instantiations
341 used by the DLL clients, use this macro to do it like this:
342
343 template <typename T> class Foo { ... };
344 WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> )
345
346 (notice that currently we only need this for wxBase and wxCore libraries)
347 */
348 #if defined(__VISUALC__) && (__VISUALC__ <= 1200)
349 #ifdef WXMAKINGDLL_BASE
350 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
351 template class WXDLLIMPEXP_BASE decl;
352 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
353 template class WXDLLIMPEXP_CORE decl;
354 #else
355 /*
356 We need to disable this warning when using this macro, as
357 recommended by Microsoft itself:
358
359 http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958
360 */
361 #pragma warning(disable:4231)
362
363 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
364 extern template class WXDLLIMPEXP_BASE decl;
365 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
366 extern template class WXDLLIMPEXP_CORE decl;
367 #endif
368 #else /* not VC <= 6 */
369 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
370 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl)
371 #endif /* VC6/others */
372
373 #endif /* _WX_DLIMPEXP_H_ */
374