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