]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dlimpexp.h
Define WXBUILDING in Xcode projects.
[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
7275146d
MW
60#elif defined(__CYGWIN__)
61# define WXEXPORT __declspec(dllexport)
62# define WXIMPORT __declspec(dllimport)
0cc66b6c
VZ
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/*
77ffb593 72 We support building wxWidgets as a set of several libraries but we don't
0cc66b6c
VZ
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
53a2db12 76 However we have a problem because we need separate WXDLLIMPEXP versions for
0cc66b6c
VZ
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
f5a9eef7 89# define WXMAKINGDLL_QA
0cc66b6c 90# define WXMAKINGDLL_HTML
0ae4d121 91# define WXMAKINGDLL_GL
0cc66b6c 92# define WXMAKINGDLL_XML
c846884b 93# define WXMAKINGDLL_XRC
5e4903f5 94# define WXMAKINGDLL_AUI
d4cd6b3e 95# define WXMAKINGDLL_PROPGRID
4dca3e02 96# define WXMAKINGDLL_RIBBON
3b2cb431 97# define WXMAKINGDLL_RICHTEXT
c220a8ec 98# define WXMAKINGDLL_MEDIA
c079af66 99# define WXMAKINGDLL_STC
467d261e 100# define WXMAKINGDLL_WEBVIEW
0cc66b6c
VZ
101#endif /* WXMAKINGDLL */
102
103/*
53a2db12 104 WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import
0cc66b6c
VZ
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
5f9c3802
SC
110# if defined(HAVE_VISIBILITY)
111# define WXDLLIMPEXP_INLINE_BASE WXEXPORT
112# else
113# define WXDLLIMPEXP_INLINE_BASE
114# endif
0cc66b6c
VZ
115#elif defined(WXUSINGDLL)
116# define WXDLLIMPEXP_BASE WXIMPORT
117# define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type
5f9c3802
SC
118# if defined(HAVE_VISIBILITY)
119# define WXDLLIMPEXP_INLINE_BASE WXIMPORT
120# else
121# define WXDLLIMPEXP_INLINE_BASE
122# endif
0cc66b6c
VZ
123#else /* not making nor using DLL */
124# define WXDLLIMPEXP_BASE
125# define WXDLLIMPEXP_DATA_BASE(type) type
5f9c3802 126# define WXDLLIMPEXP_INLINE_BASE
0cc66b6c
VZ
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
74cc3ec1
SC
143# if defined(HAVE_VISIBILITY)
144# define WXDLLIMPEXP_INLINE_CORE WXEXPORT
145# else
146# define WXDLLIMPEXP_INLINE_CORE
147# endif
0cc66b6c
VZ
148#elif defined(WXUSINGDLL)
149# define WXDLLIMPEXP_CORE WXIMPORT
150# define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type
74cc3ec1
SC
151# if defined(HAVE_VISIBILITY)
152# define WXDLLIMPEXP_INLINE_CORE WXIMPORT
153# else
154# define WXDLLIMPEXP_INLINE_CORE
155# endif
0cc66b6c
VZ
156#else /* not making nor using DLL */
157# define WXDLLIMPEXP_CORE
158# define WXDLLIMPEXP_DATA_CORE(type) type
74cc3ec1 159# define WXDLLIMPEXP_INLINE_CORE
0cc66b6c
VZ
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
61639efb
VZ
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
0cc66b6c
VZ
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
c846884b
RD
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
5e4903f5
JS
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
1c4293cb
VZ
227#ifdef WXMAKINGDLL_PROPGRID
228# define WXDLLIMPEXP_PROPGRID WXEXPORT
23318a53 229# define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type
1c4293cb
VZ
230#elif defined(WXUSINGDLL)
231# define WXDLLIMPEXP_PROPGRID WXIMPORT
23318a53 232# define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type
1c4293cb
VZ
233#else /* not making nor using DLL */
234# define WXDLLIMPEXP_PROPGRID
23318a53 235# define WXDLLIMPEXP_DATA_PROPGRID(type) type
1c4293cb
VZ
236#endif
237
4dca3e02
VZ
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
3b2cb431
JS
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
ff2b312f
RN
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
c079af66 262#ifdef WXMAKINGDLL_STC
23318a53
FM
263# define WXDLLIMPEXP_STC WXEXPORT
264# define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type
c079af66 265#elif defined(WXUSINGDLL)
23318a53
FM
266# define WXDLLIMPEXP_STC WXIMPORT
267# define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type
c079af66 268#else /* not making nor using DLL */
23318a53
FM
269# define WXDLLIMPEXP_STC
270# define WXDLLIMPEXP_DATA_STC(type) type
c079af66
VZ
271#endif
272
467d261e
SL
273#ifdef WXMAKINGDLL_WEBVIEW
274# define WXDLLIMPEXP_WEBVIEW WXEXPORT
275# define WXDLLIMPEXP_DATA_WEBVIEW(type) WXEXPORT type
384b8d9f 276#elif defined(WXUSINGDLL)
467d261e
SL
277# define WXDLLIMPEXP_WEBVIEW WXIMPORT
278# define WXDLLIMPEXP_DATA_WEBVIEW(type) WXIMPORT type
384b8d9f 279#else /* not making nor using DLL */
467d261e
SL
280# define WXDLLIMPEXP_WEBVIEW
281# define WXDLLIMPEXP_DATA_WEBVIEW(type) type
384b8d9f
SL
282#endif
283
8ece1737
VZ
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__))
0ff20b9f
VS
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
0ff20b9f
VS
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
d4cd6b3e 301 #define WXDLLIMPEXP_FWD_PROPGRID
4dca3e02 302 #define WXDLLIMPEXP_FWD_RIBBON
0ff20b9f
VS
303 #define WXDLLIMPEXP_FWD_RICHTEXT
304 #define WXDLLIMPEXP_FWD_MEDIA
305 #define WXDLLIMPEXP_FWD_STC
467d261e 306 #define WXDLLIMPEXP_FWD_WEBVIEW
0ff20b9f
VS
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
0ff20b9f
VS
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
d4cd6b3e 318 #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID
4dca3e02 319 #define WXDLLIMPEXP_FWD_RIBBON WXDLLIMPEXP_RIBBON
0ff20b9f
VS
320 #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT
321 #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA
322 #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC
467d261e 323 #define WXDLLIMPEXP_FWD_WEBVIEW WXDLLIMPEXP_WEBVIEW
0ff20b9f 324#endif
b5dbe15d 325
0cc66b6c
VZ
326/* for backwards compatibility, define suffix-less versions too */
327#define WXDLLEXPORT WXDLLIMPEXP_CORE
328#define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE
329
7c77f334
VZ
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
16361ec9 337 (notice that currently we only need this for wxBase and wxCore libraries)
7c77f334
VZ
338 */
339#if defined(__VISUALC__) && (__VISUALC__ <= 1200)
340 #ifdef WXMAKINGDLL_BASE
341 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \
342 template class WXDLLIMPEXP_BASE decl;
16361ec9
VS
343 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
344 template class WXDLLIMPEXP_CORE decl;
7c77f334
VZ
345 #else
346 /*
347 We need to disable this warning when using this macro, as
53a2db12 348 recommended by Microsoft itself:
7c77f334
VZ
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;
16361ec9
VS
356 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \
357 extern template class WXDLLIMPEXP_CORE decl;
7c77f334
VZ
358 #endif
359#else /* not VC <= 6 */
360 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl)
16361ec9 361 #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl)
7c77f334
VZ
362#endif /* VC6/others */
363
0cc66b6c
VZ
364#endif /* _WX_DLIMPEXP_H_ */
365