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