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