Macros for simplified testing Open Watcom version and required tweaks.
[wxWidgets.git] / include / wx / platform.h
1 /**
2 * Name: wx/platform.h
3 * Purpose: define the OS and compiler identification macros
4 * Author: Vadim Zeitlin
5 * Modified by:
6 * Created: 29.10.01 (extracted from wx/defs.h)
7 * RCS-ID: $Id$
8 * Copyright: (c) 1997-2001 Vadim Zeitlin
9 * Licence: wxWindows licence
10 */
11
12 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
13
14 #ifndef _WX_PLATFORM_H_
15 #define _WX_PLATFORM_H_
16
17
18 /*
19 Codewarrior doesn't define any Windows symbols until some headers
20 are included
21 */
22 #ifdef __MWERKS__
23 # include <stddef.h>
24 #endif
25
26 /*
27 WXMAC variants
28 __WXMAC_CLASSIC__ means ppc non-carbon builds, __WXMAC_CARBON__ means
29 carbon API available (mach or cfm builds) , __WXMAC_OSX__ means mach-o
30 builds, running under 10.2 + only
31 */
32 #ifdef __WXMAC__
33 # if defined(__MACH__)
34 # define __WXMAC_OSX__
35 # define __WXMAC_CARBON__
36 # ifdef __WXMAC_XCODE__
37 # include <unistd.h>
38 # include "wx/mac/carbon/config_xcode.h"
39 # endif
40 # else
41 # if TARGET_CARBON
42 # define __WXMAC_CARBON__
43 # else
44 # define __WXMAC_CLASSIC__
45 # endif
46 # endif
47 #endif
48
49 /*
50 __WXOSX__ is a common define to wxMac (Carbon) and wxCocoa ports under OS X.
51 */
52 #if defined(__WXMAC_OSX__) || defined(__WXCOCOA__)
53 # define __WXOSX__
54 #endif
55
56 /*
57 first define Windows symbols if they're not defined on the command line: we
58 can autodetect everything we need if _WIN32 is defined
59 */
60 #if defined(__CYGWIN__) && defined(__WINDOWS__)
61 # ifndef __WXMSW__
62 # define __WXMSW__
63 # endif
64
65 # ifndef _WIN32
66 # define _WIN32
67 # endif
68
69 # ifndef WIN32
70 # define WIN32
71 # endif
72 #endif
73
74 #if defined(__PALMOS__)
75 # ifndef __WXPALMOS__
76 # define __WXPALMOS__
77 # endif
78 # ifdef __WXMSW__
79 # undef __WXMSW__
80 # endif
81 # ifdef __WINDOWS__
82 # undef __WINDOWS__
83 # endif
84 # ifdef __WIN32__
85 # undef __WIN32__
86 # endif
87 # ifdef WIN32
88 # undef WIN32
89 # endif
90 # ifdef _WIN32
91 # undef _WIN32
92 # endif
93 #endif
94
95 #if defined(_WIN64)
96 # ifndef _WIN32
97 /*
98 a lot of code (mistakenly) uses #ifdef _WIN32 to either test for
99 Windows or to test for !__WIN16__, so we must define _WIN32 for
100 Win64 as well to ensure that the existing code continues to work.
101 */
102 # define _WIN32
103 # endif /* !_WIN32 */
104
105 # ifndef __WIN64__
106 # define __WIN64__
107 # endif /* !__WIN64__ */
108 #endif /* _WIN64 */
109
110 #if (defined(_WIN32) || defined(WIN32) || defined(__NT__) || defined(__WXWINCE__)) \
111 && !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__)
112 # ifndef __WXMSW__
113 # define __WXMSW__
114 # endif
115
116 # ifndef __WIN32__
117 # define __WIN32__
118 # endif
119
120 /* this means Win95-style UI, i.e. Win9x/NT 4+: always true now */
121 # if !defined(__WIN95__)
122 # define __WIN95__
123 # endif
124 #endif /* Win32 */
125
126 #if defined(__WXMSW__) || defined(__WIN32__)
127 # if !defined(__WINDOWS__)
128 # define __WINDOWS__
129 # endif
130 #endif
131
132 #ifdef __WINE__
133 # ifndef __WIN95__
134 # define __WIN95__
135 # endif
136 #endif /* WINE */
137
138 /* detect MS SmartPhone */
139 #if defined( WIN32_PLATFORM_WFSP )
140 # ifndef __SMARTPHONE__
141 # define __SMARTPHONE__
142 # endif
143 # ifndef __WXWINCE__
144 # define __WXWINCE__
145 # endif
146 #endif
147
148 /* detect PocketPC */
149 #if defined( WIN32_PLATFORM_PSPC )
150 # ifndef __POCKETPC__
151 # define __POCKETPC__
152 # endif
153 # ifndef __WXWINCE__
154 # define __WXWINCE__
155 # endif
156 #endif
157
158 /* detect Standard WinCE SDK */
159 #if defined( WCE_PLATFORM_STANDARDSDK )
160 # ifndef __WINCE_STANDARDSDK__
161 # define __WINCE_STANDARDSDK__
162 # endif
163 # ifndef __WXWINCE__
164 # define __WXWINCE__
165 # endif
166 #endif
167
168 #if defined(_WIN32_WCE) && !defined(WIN32_PLATFORM_WFSP) && !defined(WIN32_PLATFORM_PSPC)
169 # if (_WIN32_WCE >= 400)
170 # ifndef __WINCE_NET__
171 # define __WINCE_NET__
172 # endif
173 # elif (_WIN32_WCE >= 200)
174 # ifndef __HANDHELDPC__
175 # define __HANDHELDPC__
176 # endif
177 # endif
178 # ifndef __WXWINCE__
179 # define __WXWINCE__
180 # endif
181 #endif
182
183 /*
184 Include wx/setup.h for the Unix platform defines generated by configure and
185 the library compilation options
186
187 Note that it must be included before defining hardware symbols below as they
188 could be already defined by configure
189 */
190 #include "wx/setup.h"
191
192 /*
193 Hardware platform detection.
194
195 VC++ defines _M_xxx symbols.
196 */
197 #if defined(_M_IX86) || defined(i386) || defined(__i386) || defined(__i386__)
198 #ifndef __INTEL__
199 #define __INTEL__
200 #endif
201 #endif /* x86 */
202
203 #if defined(_M_IA64)
204 #ifndef __IA64__
205 #define __IA64__
206 #endif
207 #endif /* ia64 */
208
209 #if defined(_M_MPPC) || defined(__PPC__)
210 #ifndef __POWERPC__
211 #define __POWERPC__
212 #endif
213 #endif /* alpha */
214
215 #if defined(_M_ALPHA) || defined(__AXP__)
216 #ifndef __ALPHA__
217 #define __ALPHA__
218 #endif
219 #endif /* alpha */
220
221
222 /*
223 adjust the Unicode setting: wxUSE_UNICODE should be defined as 0 or 1
224 and is used by wxWidgets, _UNICODE and/or UNICODE may be defined or used by
225 the system headers so bring these settings in sync
226 */
227
228 /* set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined */
229 #if defined(_UNICODE) || defined(UNICODE)
230 # undef wxUSE_UNICODE
231 # define wxUSE_UNICODE 1
232 #else /* !UNICODE */
233 # ifndef wxUSE_UNICODE
234 # define wxUSE_UNICODE 0
235 # endif
236 #endif /* UNICODE/!UNICODE */
237
238 /* and vice versa: define UNICODE and _UNICODE if wxUSE_UNICODE is 1 */
239 #if wxUSE_UNICODE
240 # ifndef _UNICODE
241 # define _UNICODE
242 # endif
243 # ifndef UNICODE
244 # define UNICODE
245 # endif
246 #endif /* wxUSE_UNICODE */
247
248 #if defined( __MWERKS__ ) && !defined(__INTEL__)
249 // otherwise MSL headers bring in WIN32 dependant APIs
250 #undef UNICODE
251 #endif
252
253
254 /*
255 This macro can be used to test the Open Watcom version.
256 */
257 #ifndef __WATCOMC__
258 # define wxWATCOM_VERSION(major,minor) 0
259 # define wxCHECK_WATCOM_VERSION(major,minor) 0
260 # define wxONLY_WATCOM_EARLIER_THAN(major,minor) 0
261 #elif defined(__WATCOMC__) && __WATCOMC__ < 1200
262 # error "Only Open Watcom is supported in this release"
263 #else
264 # define wxWATCOM_VERSION(major,minor) ( major * 100 + minor * 10 + 1100 )
265 # define wxCHECK_WATCOM_VERSION(major,minor) ( __WATCOMC__ >= wxWATCOM_VERSION(major,minor) )
266 # define wxONLY_WATCOM_EARLIER_THAN(major,minor) ( __WATCOMC__ < wxWATCOM_VERSION(major,minor) )
267 #endif
268
269 /*
270 check the consistency of the settings in setup.h: note that this must be
271 done after setting wxUSE_UNICODE correctly as it is used in wx/chkconf.h
272 */
273 #include "wx/chkconf.h"
274
275
276 /*
277 some compilers don't support iostream.h any longer, while some of theme
278 are not updated with <iostream> yet, so override the users setting here
279 in such case.
280 */
281 #if defined(_MSC_VER) && (_MSC_VER >= 1310)
282 # undef wxUSE_IOSTREAMH
283 # define wxUSE_IOSTREAMH 0
284 #elif defined(__DMC__) || defined(__WATCOMC__)
285 # undef wxUSE_IOSTREAMH
286 # define wxUSE_IOSTREAMH 1
287 #elif defined(__MINGW32__)
288 # undef wxUSE_IOSTREAMH
289 # define wxUSE_IOSTREAMH 0
290 #endif /* compilers with/without iostream.h */
291
292 /*
293 old C++ headers (like <iostream.h>) declare classes in the global namespace
294 while the new, standard ones (like <iostream>) do it in std:: namespace,
295 unless it's an old gcc version.
296
297 using this macro allows constuctions like "wxSTD iostream" to work in
298 either case
299 */
300 #if !wxUSE_IOSTREAMH && (!defined(__GNUC__) || ( __GNUC__ > 2 ) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
301 # define wxSTD std::
302 #else
303 # define wxSTD
304 #endif
305
306 /*
307 OS: first of all, test for MS-DOS platform. We must do this before testing
308 for Unix, because DJGPP compiler defines __unix__ under MS-DOS
309 */
310 #if defined(__GO32__) || defined(__DJGPP__) || defined(__DOS__)
311 # ifndef __DOS__
312 # define __DOS__
313 # endif
314 /* size_t is the same as unsigned int for Watcom 11 compiler, */
315 /* so define it if it hadn't been done by configure yet */
316 # if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG)
317 # ifdef __WATCOMC__
318 # define wxSIZE_T_IS_UINT
319 # endif
320 # ifdef __DJGPP__
321 # define wxSIZE_T_IS_ULONG
322 # endif
323 # endif
324
325 /*
326 OS: then test for generic Unix defines, then for particular flavours and
327 finally for Unix-like systems
328 */
329 #elif defined(__UNIX__) || defined(__unix) || defined(__unix__) || \
330 defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) || \
331 defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) || \
332 defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
333
334 # define __UNIX_LIKE__
335
336 /* Helps SGI compilation, apparently */
337 # ifdef __SGI__
338 # ifdef __GNUG__
339 # define __need_wchar_t
340 # else /* !gcc */
341 /*
342 Note I use the term __SGI_CC__ for both cc and CC, its not a good
343 idea to mix gcc and cc/CC, the name mangling is different
344 */
345 # define __SGI_CC__
346 # endif /* gcc/!gcc */
347
348 /* system headers use this symbol and not __cplusplus in some places */
349 # ifndef _LANGUAGE_C_PLUS_PLUS
350 # define _LANGUAGE_C_PLUS_PLUS
351 # endif
352 # endif /* SGI */
353
354 # if defined(sun) || defined(__SUN__)
355 # ifndef __GNUG__
356 # ifndef __SUNCC__
357 # define __SUNCC__
358 # endif /* Sun CC */
359 # endif
360 # endif /* Sun */
361
362 # ifdef __EMX__
363 # define OS2EMX_PLAIN_CHAR
364 # endif
365
366 /* define __HPUX__ for HP-UX where standard macro is __hpux */
367 # if defined(__hpux) && !defined(__HPUX__)
368 # define __HPUX__
369 # endif /* HP-UX */
370
371 # if defined(__CYGWIN__) || defined(__WINE__)
372 # if !defined(wxSIZE_T_IS_UINT)
373 # define wxSIZE_T_IS_UINT
374 # endif
375 # endif
376 #elif defined(applec) || \
377 defined(THINK_C) || \
378 (defined(__MWERKS__) && !defined(__INTEL__))
379 /* MacOS */
380 # if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG)
381 # define wxSIZE_T_IS_ULONG
382 # endif
383 #elif defined(__WXMAC__) && defined(__APPLE__)
384 /* Mac OS X */
385 # define __UNIX_LIKE__
386
387 /*
388 These defines are needed when compiling using Project Builder
389 with a non generated setup0.h
390 */
391 # ifndef __UNIX__
392 # define __UNIX__ 1
393 # endif
394 # ifndef __BSD__
395 # define __BSD__ 1
396 # endif
397 # ifndef __DARWIN__
398 # define __DARWIN__ 1
399 # endif
400 # ifndef __POWERPC__
401 # define __POWERPC__ 1
402 # endif
403 # ifndef TARGET_CARBON
404 # define TARGET_CARBON 1
405 # endif
406
407 # if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG)
408 # define wxSIZE_T_IS_ULONG
409 # endif
410 /*
411 Some code has been added to workaround defects(?) in the
412 bundled gcc compiler. These corrections are identified by
413 __DARWIN__ for Darwin related corrections (wxMac, wxMotif)
414 */
415 #elif defined(__OS2__)
416
417 /* wxOS2 vs. non wxOS2 ports on OS2 platform */
418 # if !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__)
419 # ifndef __WXPM__
420 # define __WXPM__
421 # endif
422 # endif
423
424 # if defined(__IBMCPP__)
425 # define __VISAGEAVER__ __IBMCPP__
426 # endif
427
428 /* Place other OS/2 compiler environment defines here */
429 # if defined(__VISAGECPP__)
430 /* VisualAge is the only thing that understands _Optlink */
431 # define LINKAGEMODE _Optlink
432 # endif
433 # define wxSIZE_T_IS_UINT
434
435 #elif defined(__PALMOS__)
436 # ifdef __WIN32__
437 # error "__WIN32__ should not be defined for PalmOS"
438 # endif
439 # ifdef __WINDOWS__
440 # error "__WINDOWS__ should not be defined for PalmOS"
441 # endif
442 # ifdef __WXMSW__
443 # error "__WXMSW__ should not be defined for PalmOS"
444 # endif
445
446 #else /* Windows */
447 # ifndef __WINDOWS__
448 # define __WINDOWS__
449 # endif /* Windows */
450
451 /* to be changed for Win64! */
452 # ifndef __WIN32__
453 # error "__WIN32__ should be defined for Win32 and Win64, Win16 is not supported"
454 # endif
455
456 /*
457 define another standard symbol for Microsoft Visual C++: the standard
458 one (_MSC_VER) is also defined by Metrowerks compiler
459 */
460 # if defined(_MSC_VER) && !defined(__MWERKS__)
461 # define __VISUALC__ _MSC_VER
462 # elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__)
463 # define __BORLANDC__
464 # elif defined(__WATCOMC__)
465 # elif defined(__SC__)
466 # define __SYMANTECC__
467 # endif /* compiler */
468
469 /* size_t is the same as unsigned int for all Windows compilers we know, */
470 /* so define it if it hadn't been done by configure yet */
471 # if !defined(wxSIZE_T_IS_UINT) && !defined(wxSIZE_T_IS_ULONG)
472 # define wxSIZE_T_IS_UINT
473 # endif
474 #endif /* OS */
475
476 /*
477 if we're on a Unix system but didn't use configure (so that setup.h didn't
478 define __UNIX__), do define __UNIX__ now
479 */
480 #if !defined(__UNIX__) && defined(__UNIX_LIKE__)
481 # define __UNIX__
482 #endif /* Unix */
483
484 #if defined(__WXMOTIF__) || defined(__WXX11__)
485 # define __X__
486 #endif
487
488 #ifdef __SC__
489 # ifdef __DMC__
490 # define __DIGITALMARS__
491 # else
492 # define __SYMANTEC__
493 # endif
494 #endif
495
496 #ifdef __INTEL_COMPILER
497 # define __INTELC__
498 #endif
499
500 /*
501 We get "Large Files (ILP32) not supported in strict ANSI mode." #error
502 from HP-UX standard headers when compiling with g++ without this:
503 */
504 #if defined(__HPUX__) && !defined(__STDC_EXT__)
505 # define __STDC_EXT__ 1
506 #endif
507
508 /* Force linking against required libraries under Windows: */
509 #ifdef __WXWINCE__
510 # include "wx/msw/wince/libraries.h"
511 #elif defined __WINDOWS__
512 # include "wx/msw/libraries.h"
513 #endif
514
515 /*
516 This macro can be used to test the gcc version and can be used like this:
517
518 # if wxCHECK_GCC_VERSION(3, 1)
519 ... we have gcc 3.1 or later ...
520 # else
521 ... no gcc at all or gcc < 3.1 ...
522 # endif
523 */
524 #define wxCHECK_GCC_VERSION( major, minor ) \
525 ( defined(__GNUC__) && defined(__GNUC_MINOR__) \
526 && ( ( __GNUC__ > (major) ) \
527 || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) )
528
529 /*
530 This macro can be used to check that the version of mingw32 compiler is
531 at least maj.min
532 */
533 #if ( defined( __GNUWIN32__ ) || defined( __MINGW32__ ) || \
534 ( defined( __CYGWIN__ ) && defined( __WINDOWS__ ) ) || \
535 wxCHECK_WATCOM_VERSION(1,0) ) && \
536 !defined(__DOS__) && \
537 !defined(__WXPM__) && \
538 !defined(__WXMOTIF__) && \
539 !defined(__WXGTK__) && \
540 !defined(__WXX11__) && \
541 !defined(__WXPALMOS__)
542 # include "wx/msw/gccpriv.h"
543 #else
544 # undef wxCHECK_W32API_VERSION
545 # define wxCHECK_W32API_VERSION(maj, min) (0)
546 #endif
547
548 #if defined (__WXMSW__)
549 # if !defined(__WATCOMC__)
550 # define wxHAVE_RAW_BITMAP
551 # endif
552 #endif
553
554 #if defined (__WXMAC__)
555 # if !defined(WORDS_BIGENDIAN) && ( !defined(__MACH__) || ( defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ ) )
556 # define WORDS_BIGENDIAN 1
557 # endif
558 #endif
559
560 /* Choose which method we will use for updating menus
561 * - in OnIdle, or when we receive a wxEVT_MENU_OPEN event.
562 * Presently, only Windows and GTK+ support wxEVT_MENU_OPEN.
563 */
564 #ifndef wxUSE_IDLEMENUUPDATES
565 # if (defined(__WXMSW__) || defined(__WXGTK__)) && !defined(__WXUNIVERSAL__)
566 # define wxUSE_IDLEMENUUPDATES 0
567 # else
568 # define wxUSE_IDLEMENUUPDATES 1
569 # endif
570 #endif
571
572 /*
573 * Define symbols that are not yet in
574 * configure or possibly some setup.h files.
575 * They will need to be added.
576 */
577
578 #ifndef wxUSE_FILECONFIG
579 # if wxUSE_CONFIG
580 # define wxUSE_FILECONFIG 1
581 # else
582 # define wxUSE_FILECONFIG 0
583 # endif
584 #endif
585
586 #ifndef wxUSE_HOTKEY
587 # define wxUSE_HOTKEY 0
588 #endif
589
590 #if !defined(wxUSE_WXDIB) && defined(__WXMSW__)
591 # define wxUSE_WXDIB 1
592 #endif
593
594 /*
595 We need AvailabilityMacros.h for ifdefing out things that don't exist on
596 OSX 10.2 and lower
597 FIXME: We need a better way to detect for 10.3 then including a system header
598 */
599 #ifdef __DARWIN__
600 #include <AvailabilityMacros.h>
601 #endif
602
603 #endif /* _WX_PLATFORM_H_ */