]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dlimpexp.h
Partial fix for #15196: wxRichTextCell caret issues (dghart)
[wxWidgets.git] / include / wx / dlimpexp.h
CommitLineData
0cc66b6c
VZ
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)
77ffb593 7 * Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 8 * Licence: wxWindows licence
0cc66b6c
VZ
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
b9d4eff6
VS
18#if defined(HAVE_VISIBILITY)
19# define WXEXPORT __attribute__ ((visibility("default")))
20# define WXIMPORT __attribute__ ((visibility("default")))
21#elif defined(__WINDOWS__)
0cc66b6c
VZ
22 /*
23 __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
49d2c0ad 24 as VC++.
0cc66b6c 25 */
49d2c0ad 26# if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
0cc66b6c
VZ
27# define WXEXPORT __declspec(dllexport)
28# define WXIMPORT __declspec(dllimport)
49d2c0ad
VZ
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))
0cc66b6c
VZ
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
fd928524
DW
52# elif defined(__EMX__)
53# define WXEXPORT
54# define WXIMPORT
0cc66b6c
VZ
55# elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
56# define WXEXPORT _Export
57# define WXIMPORT _Export
58# endif
7275146d
MW
59#elif defined(__CYGWIN__)
60# define WXEXPORT __declspec(dllexport)
61# define WXIMPORT __declspec(dllimport)
0cc66b6c
VZ
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/*
77ffb593 71 We support building wxWidgets as a set of several libraries but we don't
0cc66b6c
VZ
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
53a2db12 75 However we have a problem because we need separate WXDLLIMPEXP versions for
0cc66b6c
VZ
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
f5a9eef7 88# define WXMAKINGDLL_QA
0cc66b6c 89# define WXMAKINGDLL_HTML
0ae4d121 90# define WXMAKINGDLL_GL
0cc66b6c 91# define WXMAKINGDLL_XML
c846884b 92# define WXMAKINGDLL_XRC
5e4903f5 93# define WXMAKINGDLL_AUI
d4cd6b3e 94# define WXMAKINGDLL_PROPGRID
4dca3e02 95# define WXMAKINGDLL_RIBBON
3b2cb431 96# define WXMAKINGDLL_RICHTEXT
c220a8ec 97# define WXMAKINGDLL_MEDIA
c079af66 98# define WXMAKINGDLL_STC
467d261e 99# define WXMAKINGDLL_WEBVIEW
0cc66b6c
VZ
100#endif /* WXMAKINGDLL */
101
102/*
53a2db12 103 WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import
0cc66b6c
VZ
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
5f9c3802
SC
109# if defined(HAVE_VISIBILITY)
110# define WXDLLIMPEXP_INLINE_BASE WXEXPORT
111# else
112# define WXDLLIMPEXP_INLINE_BASE
113# endif
0cc66b6c
VZ
114#elif defined(WXUSINGDLL)
115# define WXDLLIMPEXP_BASE WXIMPORT
116# define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type
5f9c3802
SC
117# if defined(HAVE_VISIBILITY)
118# define WXDLLIMPEXP_INLINE_BASE WXIMPORT
119# else
120# define WXDLLIMPEXP_INLINE_BASE
121# endif
0cc66b6c
VZ
122#else /* not making nor using DLL */
123# define WXDLLIMPEXP_BASE
124# define WXDLLIMPEXP_DATA_BASE(type) type
5f9c3802 125# define WXDLLIMPEXP_INLINE_BASE
0cc66b6c
VZ
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
74cc3ec1
SC
142# if defined(HAVE_VISIBILITY)
143# define WXDLLIMPEXP_INLINE_CORE WXEXPORT
144# else
145# define WXDLLIMPEXP_INLINE_CORE
146# endif
0cc66b6c
VZ
147#elif defined(WXUSINGDLL)
148# define WXDLLIMPEXP_CORE WXIMPORT
149# define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
74cc3ec1
SC
150# if defined(HAVE_VISIBILITY)
151# define WXDLLIMPEXP_INLINE_CORE WXIMPORT
152# else
153# define WXDLLIMPEXP_INLINE_CORE
154# endif
0cc66b6c
VZ
155#else /* not making nor using DLL */
156# define WXDLLIMPEXP_CORE
157# define WXDLLIMPEXP_DATA_CORE(type) type
74cc3ec1 158# define WXDLLIMPEXP_INLINE_CORE
0cc66b6c
VZ
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
61639efb
VZ
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
0cc66b6c
VZ
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
c846884b
RD
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
5e4903f5
JS
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
1c4293cb
VZ
226#ifdef WXMAKINGDLL_PROPGRID
227# define WXDLLIMPEXP_PROPGRID WXEXPORT
23318a53 228# define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type
1c4293cb
VZ
229#elif defined(WXUSINGDLL)
230# define WXDLLIMPEXP_PROPGRID WXIMPORT
23318a53 231# define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type
1c4293cb
VZ
232#else /* not making nor using DLL */
233# define WXDLLIMPEXP_PROPGRID
23318a53 234# define WXDLLIMPEXP_DATA_PROPGRID(type) type
1c4293cb
VZ
235#endif
236
4dca3e02
VZ
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
3b2cb431
JS
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
ff2b312f
RN
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
c079af66 261#ifdef WXMAKINGDLL_STC
23318a53
FM
262# define WXDLLIMPEXP_STC WXEXPORT
263# define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type
c079af66 264#elif defined(WXUSINGDLL)
23318a53
FM
265# define WXDLLIMPEXP_STC WXIMPORT
266# define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type
c079af66 267#else /* not making nor using DLL */
23318a53
FM
268# define WXDLLIMPEXP_STC
269# define WXDLLIMPEXP_DATA_STC(type) type
c079af66
VZ
270#endif
271
467d261e
SL
272#ifdef WXMAKINGDLL_WEBVIEW
273# define WXDLLIMPEXP_WEBVIEW WXEXPORT
274# define WXDLLIMPEXP_DATA_WEBVIEW(type) WXEXPORT type
384b8d9f 275#elif defined(WXUSINGDLL)
467d261e
SL
276# define WXDLLIMPEXP_WEBVIEW WXIMPORT
277# define WXDLLIMPEXP_DATA_WEBVIEW(type) WXIMPORT type
384b8d9f 278#else /* not making nor using DLL */
467d261e
SL
279# define WXDLLIMPEXP_WEBVIEW
280# define WXDLLIMPEXP_DATA_WEBVIEW(type) type
384b8d9f
SL
281#endif
282
8ece1737
VZ
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__))
0ff20b9f
VS
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
0ff20b9f
VS
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
d4cd6b3e 300 #define WXDLLIMPEXP_FWD_PROPGRID
4dca3e02 301 #define WXDLLIMPEXP_FWD_RIBBON
0ff20b9f
VS
302 #define WXDLLIMPEXP_FWD_RICHTEXT
303 #define WXDLLIMPEXP_FWD_MEDIA
304 #define WXDLLIMPEXP_FWD_STC
467d261e 305 #define WXDLLIMPEXP_FWD_WEBVIEW
0ff20b9f
VS
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
0ff20b9f
VS
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
d4cd6b3e 317 #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID
4dca3e02 318 #define WXDLLIMPEXP_FWD_RIBBON WXDLLIMPEXP_RIBBON
0ff20b9f
VS
319 #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT
320 #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA
321 #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC
467d261e 322 #define WXDLLIMPEXP_FWD_WEBVIEW WXDLLIMPEXP_WEBVIEW
0ff20b9f 323#endif
b5dbe15d 324
0cc66b6c
VZ
325/* for backwards compatibility, define suffix-less versions too */
326#define WXDLLEXPORT WXDLLIMPEXP_CORE
327#define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE
328
7c77f334
VZ
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
16361ec9 336 (notice that currently we only need this for wxBase and wxCore libraries)
7c77f334
VZ
337 */
338#if defined(__VISUALC__) && (__VISUALC__ <= 1200)
339 #ifdef WXMAKINGDLL_BASE
340 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
341 template class WXDLLIMPEXP_BASE decl;
16361ec9
VS
342 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
343 template class WXDLLIMPEXP_CORE decl;
7c77f334
VZ
344 #else
345 /*
346 We need to disable this warning when using this macro, as
53a2db12 347 recommended by Microsoft itself:
7c77f334
VZ
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;
16361ec9
VS
355 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
356 extern template class WXDLLIMPEXP_CORE decl;
7c77f334
VZ
357 #endif
358#else /* not VC <= 6 */
359 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
16361ec9 360 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl)
7c77f334
VZ
361#endif /* VC6/others */
362
0cc66b6c
VZ
363#endif /* _WX_DLIMPEXP_H_ */
364