]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dlimpexp.h
Extract PipeIOHandler class into a header and rename to wxWakeUpPipe.
[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_PROPGRID
96 # define WXMAKINGDLL_RIBBON
97 # define WXMAKINGDLL_RICHTEXT
98 # define WXMAKINGDLL_MEDIA
99 # define WXMAKINGDLL_STC
100 # define WXMAKINGDLL_WEBVIEW
101 #endif /* WXMAKINGDLL */
102
103 /*
104 WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import
105 declaration if using it or to nothing at all if we don't use wxWin as DLL
106 */
107 #ifdef WXMAKINGDLL_BASE
108 # define WXDLLIMPEXP_BASE WXEXPORT
109 # define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type
110 # if defined(HAVE_VISIBILITY)
111 # define WXDLLIMPEXP_INLINE_BASE WXEXPORT
112 # else
113 # define WXDLLIMPEXP_INLINE_BASE
114 # endif
115 #elif defined(WXUSINGDLL)
116 # define WXDLLIMPEXP_BASE WXIMPORT
117 # define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type
118 # if defined(HAVE_VISIBILITY)
119 # define WXDLLIMPEXP_INLINE_BASE WXIMPORT
120 # else
121 # define WXDLLIMPEXP_INLINE_BASE
122 # endif
123 #else /* not making nor using DLL */
124 # define WXDLLIMPEXP_BASE
125 # define WXDLLIMPEXP_DATA_BASE(type) type
126 # define WXDLLIMPEXP_INLINE_BASE
127 #endif
128
129 #ifdef WXMAKINGDLL_NET
130 # define WXDLLIMPEXP_NET WXEXPORT
131 # define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type
132 #elif defined(WXUSINGDLL)
133 # define WXDLLIMPEXP_NET WXIMPORT
134 # define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type
135 #else /* not making nor using DLL */
136 # define WXDLLIMPEXP_NET
137 # define WXDLLIMPEXP_DATA_NET(type) type
138 #endif
139
140 #ifdef WXMAKINGDLL_CORE
141 # define WXDLLIMPEXP_CORE WXEXPORT
142 # define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type
143 # if defined(HAVE_VISIBILITY)
144 # define WXDLLIMPEXP_INLINE_CORE WXEXPORT
145 # else
146 # define WXDLLIMPEXP_INLINE_CORE
147 # endif
148 #elif defined(WXUSINGDLL)
149 # define WXDLLIMPEXP_CORE WXIMPORT
150 # define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
151 # if defined(HAVE_VISIBILITY)
152 # define WXDLLIMPEXP_INLINE_CORE WXIMPORT
153 # else
154 # define WXDLLIMPEXP_INLINE_CORE
155 # endif
156 #else /* not making nor using DLL */
157 # define WXDLLIMPEXP_CORE
158 # define WXDLLIMPEXP_DATA_CORE(type) type
159 # define WXDLLIMPEXP_INLINE_CORE
160 #endif
161
162 #ifdef WXMAKINGDLL_ADV
163 # define WXDLLIMPEXP_ADV WXEXPORT
164 # define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type
165 #elif defined(WXUSINGDLL)
166 # define WXDLLIMPEXP_ADV WXIMPORT
167 # define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type
168 #else /* not making nor using DLL */
169 # define WXDLLIMPEXP_ADV
170 # define WXDLLIMPEXP_DATA_ADV(type) type
171 #endif
172
173 #ifdef WXMAKINGDLL_QA
174 # define WXDLLIMPEXP_QA WXEXPORT
175 # define WXDLLIMPEXP_DATA_QA(type) WXEXPORT type
176 #elif defined(WXUSINGDLL)
177 # define WXDLLIMPEXP_QA WXIMPORT
178 # define WXDLLIMPEXP_DATA_QA(type) WXIMPORT type
179 #else /* not making nor using DLL */
180 # define WXDLLIMPEXP_QA
181 # define WXDLLIMPEXP_DATA_QA(type) type
182 #endif
183
184 #ifdef WXMAKINGDLL_HTML
185 # define WXDLLIMPEXP_HTML WXEXPORT
186 # define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type
187 #elif defined(WXUSINGDLL)
188 # define WXDLLIMPEXP_HTML WXIMPORT
189 # define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type
190 #else /* not making nor using DLL */
191 # define WXDLLIMPEXP_HTML
192 # define WXDLLIMPEXP_DATA_HTML(type) type
193 #endif
194
195 #ifdef WXMAKINGDLL_GL
196 # define WXDLLIMPEXP_GL WXEXPORT
197 #elif defined(WXUSINGDLL)
198 # define WXDLLIMPEXP_GL WXIMPORT
199 #else /* not making nor using DLL */
200 # define WXDLLIMPEXP_GL
201 #endif
202
203 #ifdef WXMAKINGDLL_XML
204 # define WXDLLIMPEXP_XML WXEXPORT
205 #elif defined(WXUSINGDLL)
206 # define WXDLLIMPEXP_XML WXIMPORT
207 #else /* not making nor using DLL */
208 # define WXDLLIMPEXP_XML
209 #endif
210
211 #ifdef WXMAKINGDLL_XRC
212 # define WXDLLIMPEXP_XRC WXEXPORT
213 #elif defined(WXUSINGDLL)
214 # define WXDLLIMPEXP_XRC WXIMPORT
215 #else /* not making nor using DLL */
216 # define WXDLLIMPEXP_XRC
217 #endif
218
219 #ifdef WXMAKINGDLL_AUI
220 # define WXDLLIMPEXP_AUI WXEXPORT
221 #elif defined(WXUSINGDLL)
222 # define WXDLLIMPEXP_AUI WXIMPORT
223 #else /* not making nor using DLL */
224 # define WXDLLIMPEXP_AUI
225 #endif
226
227 #ifdef WXMAKINGDLL_PROPGRID
228 # define WXDLLIMPEXP_PROPGRID WXEXPORT
229 # define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type
230 #elif defined(WXUSINGDLL)
231 # define WXDLLIMPEXP_PROPGRID WXIMPORT
232 # define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type
233 #else /* not making nor using DLL */
234 # define WXDLLIMPEXP_PROPGRID
235 # define WXDLLIMPEXP_DATA_PROPGRID(type) type
236 #endif
237
238 #ifdef WXMAKINGDLL_RIBBON
239 # define WXDLLIMPEXP_RIBBON WXEXPORT
240 #elif defined(WXUSINGDLL)
241 # define WXDLLIMPEXP_RIBBON WXIMPORT
242 #else /* not making nor using DLL */
243 # define WXDLLIMPEXP_RIBBON
244 #endif
245
246 #ifdef WXMAKINGDLL_RICHTEXT
247 # define WXDLLIMPEXP_RICHTEXT WXEXPORT
248 #elif defined(WXUSINGDLL)
249 # define WXDLLIMPEXP_RICHTEXT WXIMPORT
250 #else /* not making nor using DLL */
251 # define WXDLLIMPEXP_RICHTEXT
252 #endif
253
254 #ifdef WXMAKINGDLL_MEDIA
255 # define WXDLLIMPEXP_MEDIA WXEXPORT
256 #elif defined(WXUSINGDLL)
257 # define WXDLLIMPEXP_MEDIA WXIMPORT
258 #else /* not making nor using DLL */
259 # define WXDLLIMPEXP_MEDIA
260 #endif
261
262 #ifdef WXMAKINGDLL_STC
263 # define WXDLLIMPEXP_STC WXEXPORT
264 # define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type
265 #elif defined(WXUSINGDLL)
266 # define WXDLLIMPEXP_STC WXIMPORT
267 # define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type
268 #else /* not making nor using DLL */
269 # define WXDLLIMPEXP_STC
270 # define WXDLLIMPEXP_DATA_STC(type) type
271 #endif
272
273 #ifdef WXMAKINGDLL_WEBVIEW
274 # define WXDLLIMPEXP_WEBVIEW WXEXPORT
275 # define WXDLLIMPEXP_DATA_WEBVIEW(type) WXEXPORT type
276 #elif defined(WXUSINGDLL)
277 # define WXDLLIMPEXP_WEBVIEW WXIMPORT
278 # define WXDLLIMPEXP_DATA_WEBVIEW(type) WXIMPORT type
279 #else /* not making nor using DLL */
280 # define WXDLLIMPEXP_WEBVIEW
281 # define WXDLLIMPEXP_DATA_WEBVIEW(type) type
282 #endif
283
284 /*
285 GCC warns about using __attribute__ (and also __declspec in mingw32 case) on
286 forward declarations while MSVC complains about forward declarations without
287 __declspec for the classes later declared with it, so we need a separate set
288 of macros for forward declarations to hide this difference:
289 */
290 #if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__))
291 #define WXDLLIMPEXP_FWD_BASE
292 #define WXDLLIMPEXP_FWD_NET
293 #define WXDLLIMPEXP_FWD_CORE
294 #define WXDLLIMPEXP_FWD_ADV
295 #define WXDLLIMPEXP_FWD_QA
296 #define WXDLLIMPEXP_FWD_HTML
297 #define WXDLLIMPEXP_FWD_GL
298 #define WXDLLIMPEXP_FWD_XML
299 #define WXDLLIMPEXP_FWD_XRC
300 #define WXDLLIMPEXP_FWD_AUI
301 #define WXDLLIMPEXP_FWD_PROPGRID
302 #define WXDLLIMPEXP_FWD_RIBBON
303 #define WXDLLIMPEXP_FWD_RICHTEXT
304 #define WXDLLIMPEXP_FWD_MEDIA
305 #define WXDLLIMPEXP_FWD_STC
306 #define WXDLLIMPEXP_FWD_WEBVIEW
307 #else
308 #define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE
309 #define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET
310 #define WXDLLIMPEXP_FWD_CORE WXDLLIMPEXP_CORE
311 #define WXDLLIMPEXP_FWD_ADV WXDLLIMPEXP_ADV
312 #define WXDLLIMPEXP_FWD_QA WXDLLIMPEXP_QA
313 #define WXDLLIMPEXP_FWD_HTML WXDLLIMPEXP_HTML
314 #define WXDLLIMPEXP_FWD_GL WXDLLIMPEXP_GL
315 #define WXDLLIMPEXP_FWD_XML WXDLLIMPEXP_XML
316 #define WXDLLIMPEXP_FWD_XRC WXDLLIMPEXP_XRC
317 #define WXDLLIMPEXP_FWD_AUI WXDLLIMPEXP_AUI
318 #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID
319 #define WXDLLIMPEXP_FWD_RIBBON WXDLLIMPEXP_RIBBON
320 #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT
321 #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA
322 #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC
323 #define WXDLLIMPEXP_FWD_WEBVIEW WXDLLIMPEXP_WEBVIEW
324 #endif
325
326 /* for backwards compatibility, define suffix-less versions too */
327 #define WXDLLEXPORT WXDLLIMPEXP_CORE
328 #define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE
329
330 /*
331 MSVC up to 6.0 needs to be explicitly told to export template instantiations
332 used by the DLL clients, use this macro to do it like this:
333
334 template <typename T> class Foo { ... };
335 WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> )
336
337 (notice that currently we only need this for wxBase and wxCore libraries)
338 */
339 #if defined(__VISUALC__) && (__VISUALC__ <= 1200)
340 #ifdef WXMAKINGDLL_BASE
341 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
342 template class WXDLLIMPEXP_BASE decl;
343 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
344 template class WXDLLIMPEXP_CORE decl;
345 #else
346 /*
347 We need to disable this warning when using this macro, as
348 recommended by Microsoft itself:
349
350 http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958
351 */
352 #pragma warning(disable:4231)
353
354 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
355 extern template class WXDLLIMPEXP_BASE decl;
356 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
357 extern template class WXDLLIMPEXP_CORE decl;
358 #endif
359 #else /* not VC <= 6 */
360 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
361 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl)
362 #endif /* VC6/others */
363
364 #endif /* _WX_DLIMPEXP_H_ */
365