]>
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 |
d4cd6b3e | 89 | # define WXMAKINGDLL_PROPGRID |
3b2cb431 | 90 | # define WXMAKINGDLL_RICHTEXT |
c220a8ec | 91 | # define WXMAKINGDLL_MEDIA |
c079af66 | 92 | # define WXMAKINGDLL_STC |
0cc66b6c VZ |
93 | #endif /* WXMAKINGDLL */ |
94 | ||
95 | /* | |
53a2db12 | 96 | WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import |
0cc66b6c VZ |
97 | declaration if using it or to nothing at all if we don't use wxWin as DLL |
98 | */ | |
99 | #ifdef WXMAKINGDLL_BASE | |
100 | # define WXDLLIMPEXP_BASE WXEXPORT | |
101 | # define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type | |
5f9c3802 SC |
102 | # if defined(HAVE_VISIBILITY) |
103 | # define WXDLLIMPEXP_INLINE_BASE WXEXPORT | |
104 | # else | |
105 | # define WXDLLIMPEXP_INLINE_BASE | |
106 | # endif | |
0cc66b6c VZ |
107 | #elif defined(WXUSINGDLL) |
108 | # define WXDLLIMPEXP_BASE WXIMPORT | |
109 | # define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type | |
5f9c3802 SC |
110 | # if defined(HAVE_VISIBILITY) |
111 | # define WXDLLIMPEXP_INLINE_BASE WXIMPORT | |
112 | # else | |
113 | # define WXDLLIMPEXP_INLINE_BASE | |
114 | # endif | |
0cc66b6c VZ |
115 | #else /* not making nor using DLL */ |
116 | # define WXDLLIMPEXP_BASE | |
117 | # define WXDLLIMPEXP_DATA_BASE(type) type | |
5f9c3802 | 118 | # define WXDLLIMPEXP_INLINE_BASE |
0cc66b6c VZ |
119 | #endif |
120 | ||
121 | #ifdef WXMAKINGDLL_NET | |
122 | # define WXDLLIMPEXP_NET WXEXPORT | |
123 | # define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type | |
124 | #elif defined(WXUSINGDLL) | |
125 | # define WXDLLIMPEXP_NET WXIMPORT | |
126 | # define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type | |
127 | #else /* not making nor using DLL */ | |
128 | # define WXDLLIMPEXP_NET | |
129 | # define WXDLLIMPEXP_DATA_NET(type) type | |
130 | #endif | |
131 | ||
132 | #ifdef WXMAKINGDLL_CORE | |
133 | # define WXDLLIMPEXP_CORE WXEXPORT | |
134 | # define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type | |
74cc3ec1 SC |
135 | # if defined(HAVE_VISIBILITY) |
136 | # define WXDLLIMPEXP_INLINE_CORE WXEXPORT | |
137 | # else | |
138 | # define WXDLLIMPEXP_INLINE_CORE | |
139 | # endif | |
0cc66b6c VZ |
140 | #elif defined(WXUSINGDLL) |
141 | # define WXDLLIMPEXP_CORE WXIMPORT | |
142 | # define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type | |
74cc3ec1 SC |
143 | # if defined(HAVE_VISIBILITY) |
144 | # define WXDLLIMPEXP_INLINE_CORE WXIMPORT | |
145 | # else | |
146 | # define WXDLLIMPEXP_INLINE_CORE | |
147 | # endif | |
0cc66b6c VZ |
148 | #else /* not making nor using DLL */ |
149 | # define WXDLLIMPEXP_CORE | |
150 | # define WXDLLIMPEXP_DATA_CORE(type) type | |
74cc3ec1 | 151 | # define WXDLLIMPEXP_INLINE_CORE |
0cc66b6c VZ |
152 | #endif |
153 | ||
154 | #ifdef WXMAKINGDLL_ADV | |
155 | # define WXDLLIMPEXP_ADV WXEXPORT | |
156 | # define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type | |
157 | #elif defined(WXUSINGDLL) | |
158 | # define WXDLLIMPEXP_ADV WXIMPORT | |
159 | # define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type | |
160 | #else /* not making nor using DLL */ | |
161 | # define WXDLLIMPEXP_ADV | |
162 | # define WXDLLIMPEXP_DATA_ADV(type) type | |
163 | #endif | |
164 | ||
61639efb VZ |
165 | #ifdef WXMAKINGDLL_QA |
166 | # define WXDLLIMPEXP_QA WXEXPORT | |
167 | # define WXDLLIMPEXP_DATA_QA(type) WXEXPORT type | |
168 | #elif defined(WXUSINGDLL) | |
169 | # define WXDLLIMPEXP_QA WXIMPORT | |
170 | # define WXDLLIMPEXP_DATA_QA(type) WXIMPORT type | |
171 | #else /* not making nor using DLL */ | |
172 | # define WXDLLIMPEXP_QA | |
173 | # define WXDLLIMPEXP_DATA_QA(type) type | |
174 | #endif | |
175 | ||
0cc66b6c VZ |
176 | #ifdef WXMAKINGDLL_HTML |
177 | # define WXDLLIMPEXP_HTML WXEXPORT | |
178 | # define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type | |
179 | #elif defined(WXUSINGDLL) | |
180 | # define WXDLLIMPEXP_HTML WXIMPORT | |
181 | # define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type | |
182 | #else /* not making nor using DLL */ | |
183 | # define WXDLLIMPEXP_HTML | |
184 | # define WXDLLIMPEXP_DATA_HTML(type) type | |
185 | #endif | |
186 | ||
187 | #ifdef WXMAKINGDLL_GL | |
188 | # define WXDLLIMPEXP_GL WXEXPORT | |
189 | #elif defined(WXUSINGDLL) | |
190 | # define WXDLLIMPEXP_GL WXIMPORT | |
191 | #else /* not making nor using DLL */ | |
192 | # define WXDLLIMPEXP_GL | |
193 | #endif | |
194 | ||
195 | #ifdef WXMAKINGDLL_XML | |
196 | # define WXDLLIMPEXP_XML WXEXPORT | |
197 | #elif defined(WXUSINGDLL) | |
198 | # define WXDLLIMPEXP_XML WXIMPORT | |
199 | #else /* not making nor using DLL */ | |
200 | # define WXDLLIMPEXP_XML | |
201 | #endif | |
202 | ||
c846884b RD |
203 | #ifdef WXMAKINGDLL_XRC |
204 | # define WXDLLIMPEXP_XRC WXEXPORT | |
205 | #elif defined(WXUSINGDLL) | |
206 | # define WXDLLIMPEXP_XRC WXIMPORT | |
207 | #else /* not making nor using DLL */ | |
208 | # define WXDLLIMPEXP_XRC | |
209 | #endif | |
210 | ||
5e4903f5 JS |
211 | #ifdef WXMAKINGDLL_AUI |
212 | # define WXDLLIMPEXP_AUI WXEXPORT | |
213 | #elif defined(WXUSINGDLL) | |
214 | # define WXDLLIMPEXP_AUI WXIMPORT | |
215 | #else /* not making nor using DLL */ | |
216 | # define WXDLLIMPEXP_AUI | |
217 | #endif | |
218 | ||
1c4293cb VZ |
219 | #ifdef WXMAKINGDLL_PROPGRID |
220 | # define WXDLLIMPEXP_PROPGRID WXEXPORT | |
23318a53 | 221 | # define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type |
1c4293cb VZ |
222 | #elif defined(WXUSINGDLL) |
223 | # define WXDLLIMPEXP_PROPGRID WXIMPORT | |
23318a53 | 224 | # define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type |
1c4293cb VZ |
225 | #else /* not making nor using DLL */ |
226 | # define WXDLLIMPEXP_PROPGRID | |
23318a53 | 227 | # define WXDLLIMPEXP_DATA_PROPGRID(type) type |
1c4293cb VZ |
228 | #endif |
229 | ||
3b2cb431 JS |
230 | #ifdef WXMAKINGDLL_RICHTEXT |
231 | # define WXDLLIMPEXP_RICHTEXT WXEXPORT | |
232 | #elif defined(WXUSINGDLL) | |
233 | # define WXDLLIMPEXP_RICHTEXT WXIMPORT | |
234 | #else /* not making nor using DLL */ | |
235 | # define WXDLLIMPEXP_RICHTEXT | |
236 | #endif | |
237 | ||
ff2b312f RN |
238 | #ifdef WXMAKINGDLL_MEDIA |
239 | # define WXDLLIMPEXP_MEDIA WXEXPORT | |
240 | #elif defined(WXUSINGDLL) | |
241 | # define WXDLLIMPEXP_MEDIA WXIMPORT | |
242 | #else /* not making nor using DLL */ | |
243 | # define WXDLLIMPEXP_MEDIA | |
244 | #endif | |
245 | ||
c079af66 | 246 | #ifdef WXMAKINGDLL_STC |
23318a53 FM |
247 | # define WXDLLIMPEXP_STC WXEXPORT |
248 | # define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type | |
c079af66 | 249 | #elif defined(WXUSINGDLL) |
23318a53 FM |
250 | # define WXDLLIMPEXP_STC WXIMPORT |
251 | # define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type | |
c079af66 | 252 | #else /* not making nor using DLL */ |
23318a53 FM |
253 | # define WXDLLIMPEXP_STC |
254 | # define WXDLLIMPEXP_DATA_STC(type) type | |
c079af66 VZ |
255 | #endif |
256 | ||
8ece1737 VZ |
257 | /* |
258 | GCC warns about using __attribute__ (and also __declspec in mingw32 case) on | |
259 | forward declarations while MSVC complains about forward declarations without | |
260 | __declspec for the classes later declared with it, so we need a separate set | |
261 | of macros for forward declarations to hide this difference: | |
262 | */ | |
263 | #if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__)) | |
0ff20b9f VS |
264 | #define WXDLLIMPEXP_FWD_BASE |
265 | #define WXDLLIMPEXP_FWD_NET | |
266 | #define WXDLLIMPEXP_FWD_CORE | |
267 | #define WXDLLIMPEXP_FWD_ADV | |
268 | #define WXDLLIMPEXP_FWD_QA | |
0ff20b9f VS |
269 | #define WXDLLIMPEXP_FWD_HTML |
270 | #define WXDLLIMPEXP_FWD_GL | |
271 | #define WXDLLIMPEXP_FWD_XML | |
272 | #define WXDLLIMPEXP_FWD_XRC | |
273 | #define WXDLLIMPEXP_FWD_AUI | |
d4cd6b3e | 274 | #define WXDLLIMPEXP_FWD_PROPGRID |
0ff20b9f VS |
275 | #define WXDLLIMPEXP_FWD_RICHTEXT |
276 | #define WXDLLIMPEXP_FWD_MEDIA | |
277 | #define WXDLLIMPEXP_FWD_STC | |
278 | #else | |
279 | #define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE | |
280 | #define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET | |
281 | #define WXDLLIMPEXP_FWD_CORE WXDLLIMPEXP_CORE | |
282 | #define WXDLLIMPEXP_FWD_ADV WXDLLIMPEXP_ADV | |
283 | #define WXDLLIMPEXP_FWD_QA WXDLLIMPEXP_QA | |
0ff20b9f VS |
284 | #define WXDLLIMPEXP_FWD_HTML WXDLLIMPEXP_HTML |
285 | #define WXDLLIMPEXP_FWD_GL WXDLLIMPEXP_GL | |
286 | #define WXDLLIMPEXP_FWD_XML WXDLLIMPEXP_XML | |
287 | #define WXDLLIMPEXP_FWD_XRC WXDLLIMPEXP_XRC | |
288 | #define WXDLLIMPEXP_FWD_AUI WXDLLIMPEXP_AUI | |
d4cd6b3e | 289 | #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID |
0ff20b9f VS |
290 | #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT |
291 | #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA | |
292 | #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC | |
293 | #endif | |
b5dbe15d | 294 | |
0cc66b6c VZ |
295 | /* for backwards compatibility, define suffix-less versions too */ |
296 | #define WXDLLEXPORT WXDLLIMPEXP_CORE | |
297 | #define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE | |
298 | ||
7c77f334 VZ |
299 | /* |
300 | MSVC up to 6.0 needs to be explicitly told to export template instantiations | |
301 | used by the DLL clients, use this macro to do it like this: | |
302 | ||
303 | template <typename T> class Foo { ... }; | |
304 | WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> ) | |
305 | ||
16361ec9 | 306 | (notice that currently we only need this for wxBase and wxCore libraries) |
7c77f334 VZ |
307 | */ |
308 | #if defined(__VISUALC__) && (__VISUALC__ <= 1200) | |
309 | #ifdef WXMAKINGDLL_BASE | |
310 | #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \ | |
311 | template class WXDLLIMPEXP_BASE decl; | |
16361ec9 VS |
312 | #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \ |
313 | template class WXDLLIMPEXP_CORE decl; | |
7c77f334 VZ |
314 | #else |
315 | /* | |
316 | We need to disable this warning when using this macro, as | |
53a2db12 | 317 | recommended by Microsoft itself: |
7c77f334 VZ |
318 | |
319 | http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958 | |
320 | */ | |
321 | #pragma warning(disable:4231) | |
322 | ||
323 | #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \ | |
324 | extern template class WXDLLIMPEXP_BASE decl; | |
16361ec9 VS |
325 | #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \ |
326 | extern template class WXDLLIMPEXP_CORE decl; | |
7c77f334 VZ |
327 | #endif |
328 | #else /* not VC <= 6 */ | |
329 | #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) | |
16361ec9 | 330 | #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) |
7c77f334 VZ |
331 | #endif /* VC6/others */ |
332 | ||
0cc66b6c VZ |
333 | #endif /* _WX_DLIMPEXP_H_ */ |
334 |