Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
[qt-netbsd.git] / src / corelib / global / qglobal.h
blobb237659c051e038f683477de10270cda129da669
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtCore module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
42 #ifndef QGLOBAL_H
43 #define QGLOBAL_H
45 #include <stddef.h>
47 #define QT_VERSION_STR "4.7.0"
49 QT_VERSION is (major << 16) + (minor << 8) + patch.
51 #define QT_VERSION 0x040700
53 can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
55 #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
57 #define QT_PACKAGEDATE_STR "YYYY-MM-DD"
59 #define QT_PACKAGE_TAG ""
61 #if !defined(QT_BUILD_MOC)
62 #include <QtCore/qconfig.h>
63 #endif
65 #ifdef __cplusplus
67 #ifndef QT_NAMESPACE /* user namespace */
69 # define QT_PREPEND_NAMESPACE(name) ::name
70 # define QT_USE_NAMESPACE
71 # define QT_BEGIN_NAMESPACE
72 # define QT_END_NAMESPACE
73 # define QT_BEGIN_INCLUDE_NAMESPACE
74 # define QT_END_INCLUDE_NAMESPACE
75 # define QT_BEGIN_MOC_NAMESPACE
76 # define QT_END_MOC_NAMESPACE
77 # define QT_FORWARD_DECLARE_CLASS(name) class name;
78 # define QT_FORWARD_DECLARE_STRUCT(name) struct name;
79 # define QT_MANGLE_NAMESPACE(name) name
81 #else /* user namespace */
83 # define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
84 # define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE;
85 # define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
86 # define QT_END_NAMESPACE }
87 # define QT_BEGIN_INCLUDE_NAMESPACE }
88 # define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE {
89 # define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
90 # define QT_END_MOC_NAMESPACE
91 # define QT_FORWARD_DECLARE_CLASS(name) \
92 QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \
93 using QT_PREPEND_NAMESPACE(name);
95 # define QT_FORWARD_DECLARE_STRUCT(name) \
96 QT_BEGIN_NAMESPACE struct name; QT_END_NAMESPACE \
97 using QT_PREPEND_NAMESPACE(name);
99 # define QT_MANGLE_NAMESPACE0(x) x
100 # define QT_MANGLE_NAMESPACE1(a, b) a##_##b
101 # define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b)
102 # define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \
103 QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE))
105 namespace QT_NAMESPACE {}
107 # ifndef QT_BOOTSTRAPPED
108 # ifndef QT_NO_USING_NAMESPACE
110 This expands to a "using QT_NAMESPACE" also in _header files_.
111 It is the only way the feature can be used without too much
112 pain, but if people _really_ do not want it they can add
113 DEFINES += QT_NO_USING_NAMESPACE to their .pro files.
115 QT_USE_NAMESPACE
116 # endif
117 # endif
119 #endif /* user namespace */
121 #else /* __cplusplus */
123 # define QT_BEGIN_NAMESPACE
124 # define QT_END_NAMESPACE
125 # define QT_USE_NAMESPACE
126 # define QT_BEGIN_INCLUDE_NAMESPACE
127 # define QT_END_INCLUDE_NAMESPACE
129 #endif /* __cplusplus */
131 #if defined(Q_OS_MAC) && !defined(Q_CC_INTEL)
132 #define QT_BEGIN_HEADER extern "C++" {
133 #define QT_END_HEADER }
134 #define QT_BEGIN_INCLUDE_HEADER }
135 #define QT_END_INCLUDE_HEADER extern "C++" {
136 #else
137 #define QT_BEGIN_HEADER
138 #define QT_END_HEADER
139 #define QT_BEGIN_INCLUDE_HEADER
140 #define QT_END_INCLUDE_HEADER extern "C++"
141 #endif
144 The operating system, must be one of: (Q_OS_x)
146 DARWIN - Darwin OS (synonym for Q_OS_MAC)
147 SYMBIAN - Symbian
148 MSDOS - MS-DOS and Windows
149 OS2 - OS/2
150 OS2EMX - XFree86 on OS/2 (not PM)
151 WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
152 WINCE - WinCE (Windows CE 5.0)
153 CYGWIN - Cygwin
154 SOLARIS - Sun Solaris
155 HPUX - HP-UX
156 ULTRIX - DEC Ultrix
157 LINUX - Linux
158 FREEBSD - FreeBSD
159 NETBSD - NetBSD
160 OPENBSD - OpenBSD
161 BSDI - BSD/OS
162 IRIX - SGI Irix
163 OSF - HP Tru64 UNIX
164 SCO - SCO OpenServer 5
165 UNIXWARE - UnixWare 7, Open UNIX 8
166 AIX - AIX
167 HURD - GNU Hurd
168 DGUX - DG/UX
169 RELIANT - Reliant UNIX
170 DYNIX - DYNIX/ptx
171 QNX - QNX
172 QNX6 - QNX RTP 6.1
173 LYNX - LynxOS
174 BSD4 - Any BSD 4.4 system
175 UNIX - Any UNIX BSD/SYSV system
178 #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
179 # define Q_OS_DARWIN
180 # define Q_OS_BSD4
181 # ifdef __LP64__
182 # define Q_OS_DARWIN64
183 # else
184 # define Q_OS_DARWIN32
185 # endif
186 #elif defined(__SYMBIAN32__) || defined(SYMBIAN)
187 # define Q_OS_SYMBIAN
188 # define Q_NO_POSIX_SIGNALS
189 # define QT_NO_GETIFADDRS
190 #elif defined(__CYGWIN__)
191 # define Q_OS_CYGWIN
192 #elif defined(MSDOS) || defined(_MSDOS)
193 # define Q_OS_MSDOS
194 #elif defined(__OS2__)
195 # if defined(__EMX__)
196 # define Q_OS_OS2EMX
197 # else
198 # define Q_OS_OS2
199 # endif
200 #elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
201 # define Q_OS_WIN32
202 # define Q_OS_WIN64
203 #elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
204 # if defined(WINCE) || defined(_WIN32_WCE)
205 # define Q_OS_WINCE
206 # else
207 # define Q_OS_WIN32
208 # endif
209 #elif defined(__MWERKS__) && defined(__INTEL__)
210 # define Q_OS_WIN32
211 #elif defined(__sun) || defined(sun)
212 # define Q_OS_SOLARIS
213 #elif defined(hpux) || defined(__hpux)
214 # define Q_OS_HPUX
215 #elif defined(__ultrix) || defined(ultrix)
216 # define Q_OS_ULTRIX
217 #elif defined(sinix)
218 # define Q_OS_RELIANT
219 #elif defined(__linux__) || defined(__linux)
220 # define Q_OS_LINUX
221 #elif defined(__FreeBSD__) || defined(__DragonFly__)
222 # define Q_OS_FREEBSD
223 # define Q_OS_BSD4
224 #elif defined(__NetBSD__)
225 # define Q_OS_NETBSD
226 # define Q_OS_BSD4
227 #elif defined(__OpenBSD__)
228 # define Q_OS_OPENBSD
229 # define Q_OS_BSD4
230 #elif defined(__bsdi__)
231 # define Q_OS_BSDI
232 # define Q_OS_BSD4
233 #elif defined(__sgi)
234 # define Q_OS_IRIX
235 #elif defined(__osf__)
236 # define Q_OS_OSF
237 #elif defined(_AIX)
238 # define Q_OS_AIX
239 #elif defined(__Lynx__)
240 # define Q_OS_LYNX
241 #elif defined(__GNU__)
242 # define Q_OS_HURD
243 #elif defined(__DGUX__)
244 # define Q_OS_DGUX
245 #elif defined(__QNXNTO__)
246 # define Q_OS_QNX
247 #elif defined(_SEQUENT_)
248 # define Q_OS_DYNIX
249 #elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */
250 # define Q_OS_SCO
251 #elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */
252 # define Q_OS_UNIXWARE
253 #elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */
254 # define Q_OS_UNIXWARE
255 #elif defined(__INTEGRITY)
256 # define Q_OS_INTEGRITY
257 #elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
258 # define Q_OS_VXWORKS
259 #elif defined(__MAKEDEPEND__)
260 #else
261 # error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com"
262 #endif
264 #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE)
265 # define Q_OS_WIN
266 #endif
268 #if defined(Q_OS_DARWIN)
269 # define Q_OS_MAC /* Q_OS_MAC is mostly for compatibility, but also more clear */
270 # define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/
271 # if defined(Q_OS_DARWIN64)
272 # define Q_OS_MAC64
273 # elif defined(Q_OS_DARWIN32)
274 # define Q_OS_MAC32
275 # endif
276 #endif
278 #ifdef QT_AUTODETECT_COCOA
279 # ifdef Q_OS_MAC64
280 # define QT_MAC_USE_COCOA 1
281 # define QT_BUILD_KEY QT_BUILD_KEY_COCOA
282 # else
283 # define QT_BUILD_KEY QT_BUILD_KEY_CARBON
284 # endif
285 #endif
287 #if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE)
288 #error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration."
289 #endif
291 #if defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN)
292 # undef Q_OS_UNIX
293 #elif !defined(Q_OS_UNIX)
294 # define Q_OS_UNIX
295 #endif
297 #if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT)
298 # define QT_LARGEFILE_SUPPORT 64
299 #endif
301 #ifdef Q_OS_DARWIN
302 # ifdef MAC_OS_X_VERSION_MIN_REQUIRED
303 # undef MAC_OS_X_VERSION_MIN_REQUIRED
304 # endif
305 # define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
306 # include <AvailabilityMacros.h>
307 # if !defined(MAC_OS_X_VERSION_10_3)
308 # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1
309 # endif
310 # if !defined(MAC_OS_X_VERSION_10_4)
311 # define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1
312 # endif
313 # if !defined(MAC_OS_X_VERSION_10_5)
314 # define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1
315 # endif
316 # if !defined(MAC_OS_X_VERSION_10_6)
317 # define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1
318 # endif
319 # if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6)
320 # warning "This version of Mac OS X is unsupported"
321 # endif
322 #endif
324 #ifdef __LSB_VERSION__
325 # if __LSB_VERSION__ < 40
326 # error "This version of the Linux Standard Base is unsupported"
327 # endif
328 #ifndef QT_LINUXBASE
329 # define QT_LINUXBASE
330 #endif
331 #endif
334 The compiler, must be one of: (Q_CC_x)
336 SYM - Digital Mars C/C++ (used to be Symantec C++)
337 MWERKS - Metrowerks CodeWarrior
338 MSVC - Microsoft Visual C/C++, Intel C++ for Windows
339 BOR - Borland/Turbo C++
340 WAT - Watcom C++
341 GNU - GNU C++
342 COMEAU - Comeau C++
343 EDG - Edison Design Group C++
344 OC - CenterLine C++
345 SUN - Forte Developer, or Sun Studio C++
346 MIPS - MIPSpro C++
347 DEC - DEC C++
348 HPACC - HP aC++
349 USLC - SCO OUDK and UDK
350 CDS - Reliant C++
351 KAI - KAI C++
352 INTEL - Intel C++ for Linux, Intel C++ for Windows
353 HIGHC - MetaWare High C/C++
354 PGI - Portland Group C++
355 GHS - Green Hills Optimizing C++ Compilers
356 GCCE - GCCE (Symbian GCCE builds)
357 RVCT - ARM Realview Compiler Suite
358 NOKIAX86 - Nokia x86 (Symbian WINSCW builds)
361 Should be sorted most to least authoritative.
364 #if defined(__ghs)
365 # define Q_OUTOFLINE_TEMPLATE inline
366 #endif
368 /* Symantec C++ is now Digital Mars */
369 #if defined(__DMC__) || defined(__SC__)
370 # define Q_CC_SYM
371 /* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */
372 # if defined(__SC__) && __SC__ < 0x750
373 # define Q_NO_EXPLICIT_KEYWORD
374 # endif
375 # define Q_NO_USING_KEYWORD
377 #elif defined(__MWERKS__)
378 # define Q_CC_MWERKS
379 # if defined(__EMU_SYMBIAN_OS__)
380 # define Q_CC_NOKIAX86
381 # endif
382 /* "explicit" recognized since 4.0d1 */
384 #elif defined(_MSC_VER)
385 # define Q_CC_MSVC
386 /* proper support of bool for _MSC_VER >= 1100 */
387 # define Q_CANNOT_DELETE_CONSTANT
388 # define Q_OUTOFLINE_TEMPLATE inline
389 # define Q_NO_TEMPLATE_FRIENDS
390 # define QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
391 # define Q_ALIGNOF(type) __alignof(type)
392 # define Q_DECL_ALIGN(n) __declspec(align(n))
394 /* Visual C++.Net issues for _MSC_VER >= 1300 */
395 # if _MSC_VER >= 1300
396 # define Q_CC_MSVC_NET
397 # if _MSC_VER < 1310 || (defined(Q_OS_WIN64) && defined(_M_IA64))
398 # define Q_TYPENAME
399 # else
400 # undef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
401 # endif
402 # else
403 # define Q_NO_USING_KEYWORD
404 # define QT_NO_MEMBER_TEMPLATES
405 # endif
406 # if _MSC_VER < 1310
407 # define QT_NO_QOBJECT_CHECK
408 # define Q_TYPENAME
409 # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
410 # endif
411 /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
412 # if defined(__INTEL_COMPILER)
413 # define Q_CC_INTEL
414 # endif
415 /* x64 does not support mmx intrinsics on windows */
416 # if (defined(Q_OS_WIN64) && defined(_M_X64))
417 # undef QT_HAVE_SSE
418 # undef QT_HAVE_SSE2
419 # undef QT_HAVE_MMX
420 # undef QT_HAVE_3DNOW
421 # endif
424 #elif defined(__BORLANDC__) || defined(__TURBOC__)
425 # define Q_CC_BOR
426 # define Q_INLINE_TEMPLATE
427 # if __BORLANDC__ < 0x502
428 # define Q_NO_BOOL_TYPE
429 # define Q_NO_EXPLICIT_KEYWORD
430 # endif
431 # define Q_NO_USING_KEYWORD
433 #elif defined(__WATCOMC__)
434 # define Q_CC_WAT
436 /* Symbian GCCE */
437 #elif defined(__GCCE__)
438 # define Q_CC_GCCE
439 # define QT_VISIBILITY_AVAILABLE
440 # if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)
441 # define QT_HAVE_ARMV6
442 # endif
444 /* ARM Realview Compiler Suite
445 RVCT compiler also defines __EDG__ and __GNUC__ (if --gnu flag is given),
446 so check for it before that */
447 #elif defined(__ARMCC__) || defined(__CC_ARM)
448 # define Q_CC_RVCT
449 # if __TARGET_ARCH_ARM >= 6
450 # define QT_HAVE_ARMV6
451 # endif
452 #elif defined(__GNUC__)
453 # define Q_CC_GNU
454 # define Q_C_CALLBACKS
455 # if defined(__MINGW32__)
456 # define Q_CC_MINGW
457 # endif
458 # if defined(__INTEL_COMPILER)
459 /* Intel C++ also masquerades as GCC 3.2.0 */
460 # define Q_CC_INTEL
461 # define Q_NO_TEMPLATE_FRIENDS
462 # endif
463 # ifdef __APPLE__
464 # define Q_NO_DEPRECATED_CONSTRUCTORS
465 # endif
466 # if __GNUC__ == 2 && __GNUC_MINOR__ <= 7
467 # define Q_FULL_TEMPLATE_INSTANTIATION
468 # endif
469 /* GCC 2.95 knows "using" but does not support it correctly */
470 # if __GNUC__ == 2 && __GNUC_MINOR__ <= 95
471 # define Q_NO_USING_KEYWORD
472 # define QT_NO_STL_WCHAR
473 # endif
474 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
475 # define Q_ALIGNOF(type) __alignof__(type)
476 # define Q_TYPEOF(expr) __typeof__(expr)
477 # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
478 # endif
479 /* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
480 # if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
481 # define Q_WRONG_SB_CTYPE_MACROS
482 # endif
483 /* GCC <= 3.3 cannot handle template friends */
484 # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
485 # define Q_NO_TEMPLATE_FRIENDS
486 # endif
487 /* Apple's GCC 3.1 chokes on our streaming qDebug() */
488 # if defined(Q_OS_DARWIN) && __GNUC__ == 3 && (__GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 3)
489 # define Q_BROKEN_DEBUG_STREAM
490 # endif
491 # if (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) && !defined(QT_MOC_CPP)
492 # define Q_PACKED __attribute__ ((__packed__))
493 # define Q_NO_PACKED_REFERENCE
494 # ifndef __ARM_EABI__
495 # define QT_NO_ARM_EABI
496 # endif
497 # endif
499 /* IBM compiler versions are a bit messy. There are actually two products:
500 the C product, and the C++ product. The C++ compiler is always packaged
501 with the latest version of the C compiler. Version numbers do not always
502 match. This little table (I'm not sure it's accurate) should be helpful:
504 C++ product C product
506 C Set 3.1 C Compiler 3.0
507 ... ...
508 C++ Compiler 3.6.6 C Compiler 4.3
509 ... ...
510 Visual Age C++ 4.0 ...
511 ... ...
512 Visual Age C++ 5.0 C Compiler 5.0
513 ... ...
514 Visual Age C++ 6.0 C Compiler 6.0
516 Now:
517 __xlC__ is the version of the C compiler in hexadecimal notation
518 is only an approximation of the C++ compiler version
519 __IBMCPP__ is the version of the C++ compiler in decimal notation
520 but it is not defined on older compilers like C Set 3.1 */
521 #elif defined(__xlC__)
522 # define Q_CC_XLC
523 # define Q_FULL_TEMPLATE_INSTANTIATION
524 # if __xlC__ < 0x400
525 # define Q_NO_BOOL_TYPE
526 # define Q_NO_EXPLICIT_KEYWORD
527 # define Q_NO_USING_KEYWORD
528 # define Q_TYPENAME
529 # define Q_OUTOFLINE_TEMPLATE inline
530 # define Q_BROKEN_TEMPLATE_SPECIALIZATION
531 # define Q_CANNOT_DELETE_CONSTANT
532 # elif __xlC__ >= 0x0600
533 # define Q_ALIGNOF(type) __alignof__(type)
534 # define Q_TYPEOF(expr) __typeof__(expr)
535 # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
536 # define Q_PACKED __attribute__((__packed__))
537 # endif
539 /* Older versions of DEC C++ do not define __EDG__ or __EDG - observed
540 on DEC C++ V5.5-004. New versions do define __EDG__ - observed on
541 Compaq C++ V6.3-002.
542 This compiler is different enough from other EDG compilers to handle
543 it separately anyway. */
544 #elif defined(__DECCXX) || defined(__DECC)
545 # define Q_CC_DEC
546 /* Compaq C++ V6 compilers are EDG-based but I'm not sure about older
547 DEC C++ V5 compilers. */
548 # if defined(__EDG__)
549 # define Q_CC_EDG
550 # endif
551 /* Compaq have disabled EDG's _BOOL macro and use _BOOL_EXISTS instead
552 - observed on Compaq C++ V6.3-002.
553 In any case versions prior to Compaq C++ V6.0-005 do not have bool. */
554 # if !defined(_BOOL_EXISTS)
555 # define Q_NO_BOOL_TYPE
556 # endif
557 /* Spurious (?) error messages observed on Compaq C++ V6.5-014. */
558 # define Q_NO_USING_KEYWORD
559 /* Apply to all versions prior to Compaq C++ V6.0-000 - observed on
560 DEC C++ V5.5-004. */
561 # if __DECCXX_VER < 60060000
562 # define Q_TYPENAME
563 # define Q_BROKEN_TEMPLATE_SPECIALIZATION
564 # define Q_CANNOT_DELETE_CONSTANT
565 # endif
566 /* avoid undefined symbol problems with out-of-line template members */
567 # define Q_OUTOFLINE_TEMPLATE inline
569 /* The Portland Group C++ compiler is based on EDG and does define __EDG__
570 but the C compiler does not */
571 #elif defined(__PGI)
572 # define Q_CC_PGI
573 # if defined(__EDG__)
574 # define Q_CC_EDG
575 # endif
577 /* Compilers with EDG front end are similar. To detect them we test:
578 __EDG documented by SGI, observed on MIPSpro 7.3.1.1 and KAI C++ 4.0b
579 __EDG__ documented in EDG online docs, observed on Compaq C++ V6.3-002
580 and PGI C++ 5.2-4 */
581 #elif !defined(Q_OS_HPUX) && (defined(__EDG) || defined(__EDG__))
582 # define Q_CC_EDG
583 /* From the EDG documentation (does not seem to apply to Compaq C++):
584 _BOOL
585 Defined in C++ mode when bool is a keyword. The name of this
586 predefined macro is specified by a configuration flag. _BOOL
587 is the default.
588 __BOOL_DEFINED
589 Defined in Microsoft C++ mode when bool is a keyword. */
590 # if !defined(_BOOL) && !defined(__BOOL_DEFINED)
591 # define Q_NO_BOOL_TYPE
592 # endif
594 /* The Comeau compiler is based on EDG and does define __EDG__ */
595 # if defined(__COMO__)
596 # define Q_CC_COMEAU
597 # define Q_C_CALLBACKS
599 /* The `using' keyword was introduced to avoid KAI C++ warnings
600 but it's now causing KAI C++ errors instead. The standard is
601 unclear about the use of this keyword, and in practice every
602 compiler is using its own set of rules. Forget it. */
603 # elif defined(__KCC)
604 # define Q_CC_KAI
605 # define Q_NO_USING_KEYWORD
607 /* Using the `using' keyword avoids Intel C++ for Linux warnings */
608 # elif defined(__INTEL_COMPILER)
609 # define Q_CC_INTEL
611 /* Uses CFront, make sure to read the manual how to tweak templates. */
612 # elif defined(__ghs)
613 # define Q_CC_GHS
615 # elif defined(__DCC__)
616 # define Q_CC_DIAB
617 # undef Q_NO_BOOL_TYPE
618 # if !defined(__bool)
619 # define Q_NO_BOOL_TYPE
620 # endif
622 /* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */
623 # elif defined(__USLC__) && defined(__SCO_VERSION__)
624 # define Q_CC_USLC
625 /* The latest UDK 7.1.1b does not need this, but previous versions do */
626 # if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010)
627 # define Q_OUTOFLINE_TEMPLATE inline
628 # endif
629 # define Q_NO_USING_KEYWORD /* ### check "using" status */
631 /* Never tested! */
632 # elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER)
633 # define Q_CC_OC
634 # define Q_NO_USING_KEYWORD
636 /* CDS++ defines __EDG__ although this is not documented in the Reliant
637 documentation. It also follows conventions like _BOOL and this documented */
638 # elif defined(sinix)
639 # define Q_CC_CDS
640 # define Q_NO_USING_KEYWORD
642 /* The MIPSpro compiler defines __EDG */
643 # elif defined(__sgi)
644 # define Q_CC_MIPS
645 # define Q_NO_USING_KEYWORD /* ### check "using" status */
646 # define Q_NO_TEMPLATE_FRIENDS
647 # if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 740)
648 # define Q_OUTOFLINE_TEMPLATE inline
649 # pragma set woff 3624,3625,3649 /* turn off some harmless warnings */
650 # endif
651 # endif
653 /* VxWorks' DIAB toolchain has an additional EDG type C++ compiler
654 (see __DCC__ above). This one is for C mode files (__EDG is not defined) */
655 #elif defined(_DIAB_TOOL)
656 # define Q_CC_DIAB
658 /* Never tested! */
659 #elif defined(__HIGHC__)
660 # define Q_CC_HIGHC
662 #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
663 # define Q_CC_SUN
664 /* 5.0 compiler or better
665 'bool' is enabled by default but can be disabled using -features=nobool
666 in which case _BOOL is not defined
667 this is the default in 4.2 compatibility mode triggered by -compat=4 */
668 # if __SUNPRO_CC >= 0x500
669 # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
670 /* see http://developers.sun.com/sunstudio/support/Ccompare.html */
671 # if __SUNPRO_CC >= 0x590
672 # define Q_ALIGNOF(type) __alignof__(type)
673 # define Q_TYPEOF(expr) __typeof__(expr)
674 # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
675 # endif
676 # if __SUNPRO_CC >= 0x550
677 # define Q_DECL_EXPORT __global
678 # endif
679 # if __SUNPRO_CC < 0x5a0
680 # define Q_NO_TEMPLATE_FRIENDS
681 # endif
682 # if !defined(_BOOL)
683 # define Q_NO_BOOL_TYPE
684 # endif
685 # if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4)
686 # define Q_NO_USING_KEYWORD
687 # endif
688 # define Q_C_CALLBACKS
689 /* 4.2 compiler or older */
690 # else
691 # define Q_NO_BOOL_TYPE
692 # define Q_NO_EXPLICIT_KEYWORD
693 # define Q_NO_USING_KEYWORD
694 # endif
696 /* CDS++ does not seem to define __EDG__ or __EDG according to Reliant
697 documentation but nevertheless uses EDG conventions like _BOOL */
698 #elif defined(sinix)
699 # define Q_CC_EDG
700 # define Q_CC_CDS
701 # if !defined(_BOOL)
702 # define Q_NO_BOOL_TYPE
703 # endif
704 # define Q_BROKEN_TEMPLATE_SPECIALIZATION
706 #elif defined(Q_OS_HPUX)
707 /* __HP_aCC was not defined in first aCC releases */
708 # if defined(__HP_aCC) || __cplusplus >= 199707L
709 # define Q_NO_TEMPLATE_FRIENDS
710 # define Q_CC_HPACC
711 # if __HP_aCC-0 < 060000
712 # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
713 # define Q_DECL_EXPORT __declspec(dllexport)
714 # define Q_DECL_IMPORT __declspec(dllimport)
715 # endif
716 # if __HP_aCC-0 >= 061200
717 # define Q_DECL_ALIGNED(n) __attribute__((aligned(n)))
718 # endif
719 # if __HP_aCC-0 >= 062000
720 # define Q_DECL_EXPORT __attribute__((visibility("default")))
721 # define Q_DECL_IMPORT Q_DECL_EXPORT
722 # endif
723 # else
724 # define Q_CC_HP
725 # define Q_NO_BOOL_TYPE
726 # define Q_FULL_TEMPLATE_INSTANTIATION
727 # define Q_BROKEN_TEMPLATE_SPECIALIZATION
728 # define Q_NO_EXPLICIT_KEYWORD
729 # endif
730 # define Q_NO_USING_KEYWORD /* ### check "using" status */
732 #elif defined(__WINSCW__) && !defined(Q_CC_NOKIAX86)
733 # define Q_CC_NOKIAX86
736 #else
737 # error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com"
738 #endif
740 #ifndef Q_PACKED
741 # define Q_PACKED
742 # undef Q_NO_PACKED_REFERENCE
743 #endif
745 #ifndef Q_CONSTRUCTOR_FUNCTION
746 # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
747 static const int AFUNC ## __init_variable__ = AFUNC();
748 # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
749 #endif
751 #ifndef Q_DESTRUCTOR_FUNCTION
752 # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
753 class AFUNC ## __dest_class__ { \
754 public: \
755 inline AFUNC ## __dest_class__() { } \
756 inline ~ AFUNC ## __dest_class__() { AFUNC(); } \
757 } AFUNC ## __dest_instance__;
758 # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
759 #endif
761 #ifndef Q_REQUIRED_RESULT
762 # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
763 # define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result))
764 # else
765 # define Q_REQUIRED_RESULT
766 # endif
767 #endif
769 #ifndef Q_COMPILER_MANGLES_RETURN_TYPE
770 # if defined(Q_CC_MSVC)
771 # define Q_COMPILER_MANGLES_RETURN_TYPE
772 # endif
773 #endif
776 The window system, must be one of: (Q_WS_x)
778 MACX - Mac OS X
779 MAC9 - Mac OS 9
780 QWS - Qt for Embedded Linux
781 WIN32 - Windows
782 X11 - X Window System
783 S60 - Symbian S60
784 PM - unsupported
785 WIN16 - unsupported
788 #if defined(Q_OS_MSDOS)
789 # define Q_WS_WIN16
790 # error "Qt requires Win32 and does not work with Windows 3.x"
791 #elif defined(_WIN32_X11_)
792 # define Q_WS_X11
793 #elif defined(Q_OS_WIN32)
794 # define Q_WS_WIN32
795 # if defined(Q_OS_WIN64)
796 # define Q_WS_WIN64
797 # endif
798 #elif defined(Q_OS_WINCE)
799 # define Q_WS_WIN32
800 # define Q_WS_WINCE
801 # if defined(Q_OS_WINCE_WM)
802 # define Q_WS_WINCE_WM
803 # endif
804 #elif defined(Q_OS_OS2)
805 # define Q_WS_PM
806 # error "Qt does not work with OS/2 Presentation Manager or Workplace Shell"
807 #elif defined(Q_OS_UNIX)
808 # if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS)
809 # define Q_WS_MAC
810 # define Q_WS_MACX
811 # if defined(Q_OS_MAC64)
812 # define Q_WS_MAC64
813 # elif defined(Q_OS_MAC32)
814 # define Q_WS_MAC32
815 # endif
816 # elif defined(Q_OS_SYMBIAN)
817 # if (defined(__SERIES60_31__) || defined(__S60_32__) || defined(__S60_50__)) && !defined(QT_NO_S60)
818 # define Q_WS_S60
819 # endif
820 # elif !defined(Q_WS_QWS)
821 # define Q_WS_X11
822 # endif
823 #endif
825 #if defined(Q_WS_WIN16) || defined(Q_WS_WIN32) || defined(Q_WS_WINCE)
826 # define Q_WS_WIN
827 #endif
829 QT_BEGIN_HEADER
830 QT_BEGIN_NAMESPACE
833 Size-dependent types (architechture-dependent byte order)
835 Make sure to update QMetaType when changing these typedefs
838 typedef signed char qint8; /* 8 bit signed */
839 typedef unsigned char quint8; /* 8 bit unsigned */
840 typedef short qint16; /* 16 bit signed */
841 typedef unsigned short quint16; /* 16 bit unsigned */
842 typedef int qint32; /* 32 bit signed */
843 typedef unsigned int quint32; /* 32 bit unsigned */
844 #if defined(Q_OS_WIN) && !defined(Q_CC_GNU) && !defined(Q_CC_MWERKS)
845 # define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */
846 # define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
847 typedef __int64 qint64; /* 64 bit signed */
848 typedef unsigned __int64 quint64; /* 64 bit unsigned */
849 #else
850 # define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
851 # define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
852 typedef long long qint64; /* 64 bit signed */
853 typedef unsigned long long quint64; /* 64 bit unsigned */
854 #endif
856 typedef qint64 qlonglong;
857 typedef quint64 qulonglong;
859 #ifndef QT_POINTER_SIZE
860 # if defined(Q_OS_WIN64)
861 # define QT_POINTER_SIZE 8
862 # elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
863 # define QT_POINTER_SIZE 4
864 # endif
865 #endif
867 #define Q_INIT_RESOURCE(name) \
868 do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \
869 QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0)
870 #define Q_CLEANUP_RESOURCE(name) \
871 do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \
872 QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0)
874 #if defined(__cplusplus)
877 quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
879 sizeof(void *) == sizeof(quintptr)
880 && sizeof(void *) == sizeof(qptrdiff)
882 template <int> struct QIntegerForSize;
883 template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; };
884 template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
885 template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
886 template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
887 template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
888 typedef QIntegerForSizeof<void*>::Unsigned quintptr;
889 typedef QIntegerForSizeof<void*>::Signed qptrdiff;
892 Useful type definitions for Qt
895 QT_BEGIN_INCLUDE_NAMESPACE
896 typedef unsigned char uchar;
897 typedef unsigned short ushort;
898 typedef unsigned int uint;
899 typedef unsigned long ulong;
900 QT_END_INCLUDE_NAMESPACE
902 #if defined(Q_NO_BOOL_TYPE)
903 #error "Compiler doesn't support the bool type"
904 #endif
907 Constant bool values
910 #ifndef QT_LINUXBASE /* the LSB defines TRUE and FALSE for us */
911 /* Symbian OS defines TRUE = 1 and FALSE = 0,
912 redefine to built-in booleans to make autotests work properly */
913 #ifdef Q_OS_SYMBIAN
914 #include <e32def.h> /* Symbian OS defines */
916 #undef TRUE
917 #undef FALSE
918 #endif
919 # ifndef TRUE
920 # define TRUE true
921 # define FALSE false
922 # endif
923 #endif
926 Proper for-scoping in VC++6 and MIPSpro CC
928 #ifndef QT_NO_KEYWORDS
929 # if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
930 # define for if(0){}else for
931 # endif
932 #endif
935 Workaround for static const members on MSVC++.
938 #if defined(Q_CC_MSVC)
939 # define QT_STATIC_CONST static
940 # define QT_STATIC_CONST_IMPL
941 #else
942 # define QT_STATIC_CONST static const
943 # define QT_STATIC_CONST_IMPL const
944 #endif
947 Warnings and errors when using deprecated methods
949 #if defined(Q_MOC_RUN)
950 # define Q_DECL_DEPRECATED Q_DECL_DEPRECATED
951 #elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT)
952 # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
953 #elif defined(Q_CC_MSVC) && (_MSC_VER >= 1300)
954 # define Q_DECL_DEPRECATED __declspec(deprecated)
955 # if defined (Q_CC_INTEL)
956 # define Q_DECL_VARIABLE_DEPRECATED
957 # else
958 # endif
959 #else
960 # define Q_DECL_DEPRECATED
961 #endif
962 #ifndef Q_DECL_VARIABLE_DEPRECATED
963 # define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
964 #endif
965 #ifndef Q_DECL_CONSTRUCTOR_DEPRECATED
966 # if defined(Q_MOC_RUN)
967 # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED
968 # elif defined(Q_NO_DEPRECATED_CONSTRUCTORS)
969 # define Q_DECL_CONSTRUCTOR_DEPRECATED
970 # else
971 # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED
972 # endif
973 #endif
975 #if defined(QT_NO_DEPRECATED)
976 /* disable Qt3 support as well */
977 # undef QT3_SUPPORT_WARNINGS
978 # undef QT3_SUPPORT
979 # undef QT_DEPRECATED
980 # undef QT_DEPRECATED_VARIABLE
981 # undef QT_DEPRECATED_CONSTRUCTOR
982 #elif defined(QT_DEPRECATED_WARNINGS)
983 /* enable Qt3 support warnings as well */
984 # undef QT3_SUPPORT_WARNINGS
985 # define QT3_SUPPORT_WARNINGS
986 # undef QT_DEPRECATED
987 # define QT_DEPRECATED Q_DECL_DEPRECATED
988 # undef QT_DEPRECATED_VARIABLE
989 # define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
990 # undef QT_DEPRECATED_CONSTRUCTOR
991 # define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
992 #else
993 # undef QT_DEPRECATED
994 # define QT_DEPRECATED
995 # undef QT_DEPRECATED_VARIABLE
996 # define QT_DEPRECATED_VARIABLE
997 # undef QT_DEPRECATED_CONSTRUCTOR
998 # define QT_DEPRECATED_CONSTRUCTOR
999 #endif
1001 #if defined(QT3_SUPPORT_WARNINGS)
1002 # if !defined(QT_COMPAT_WARNINGS) /* also enable compat */
1003 # define QT_COMPAT_WARNINGS
1004 # endif
1005 # undef QT3_SUPPORT
1006 # define QT3_SUPPORT Q_DECL_DEPRECATED
1007 # undef QT3_SUPPORT_VARIABLE
1008 # define QT3_SUPPORT_VARIABLE Q_DECL_VARIABLE_DEPRECATED
1009 # undef QT3_SUPPORT_CONSTRUCTOR
1010 # define QT3_SUPPORT_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
1011 #elif defined(QT3_SUPPORT) /* define back to nothing */
1012 # if !defined(QT_COMPAT) /* also enable qt3 support */
1013 # define QT_COMPAT
1014 # endif
1015 # undef QT3_SUPPORT
1016 # define QT3_SUPPORT
1017 # undef QT3_SUPPORT_VARIABLE
1018 # define QT3_SUPPORT_VARIABLE
1019 # undef QT3_SUPPORT_CONSTRUCTOR
1020 # define QT3_SUPPORT_CONSTRUCTOR explicit
1021 #endif
1023 /* moc compats (signals/slots) */
1024 #ifndef QT_MOC_COMPAT
1025 # if defined(QT3_SUPPORT)
1026 # define QT_MOC_COMPAT QT3_SUPPORT
1027 # else
1028 # define QT_MOC_COMPAT
1029 # endif
1030 #else
1031 # undef QT_MOC_COMPAT
1032 # define QT_MOC_COMPAT
1033 #endif
1035 #ifdef QT_ASCII_CAST_WARNINGS
1036 # define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED
1037 # if defined(Q_CC_GNU) && __GNUC__ < 4
1038 /* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */
1039 # define QT_ASCII_CAST_WARN_CONSTRUCTOR
1040 # else
1041 # define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED
1042 # endif
1043 #else
1044 # define QT_ASCII_CAST_WARN
1045 # define QT_ASCII_CAST_WARN_CONSTRUCTOR
1046 #endif
1048 #if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
1049 # if defined(Q_CC_GNU)
1050 #if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
1051 # define QT_FASTCALL __attribute__((regparm(3)))
1052 #else
1053 # define QT_FASTCALL
1054 #endif
1055 # elif defined(Q_CC_MSVC) && (_MSC_VER > 1300 || defined(Q_CC_INTEL))
1056 # define QT_FASTCALL __fastcall
1057 # else
1058 # define QT_FASTCALL
1059 # endif
1060 #else
1061 # define QT_FASTCALL
1062 #endif
1064 typedef int QNoImplicitBoolCast;
1066 #if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A)
1067 #define QT_NO_FPU
1068 #endif
1070 // This logic must match the one in qmetatype.h
1071 #if defined(QT_COORD_TYPE)
1072 typedef QT_COORD_TYPE qreal;
1073 #elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
1074 typedef float qreal;
1075 #else
1076 typedef double qreal;
1077 #endif
1080 Utility macros and inline functions
1083 template <typename T>
1084 inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
1086 inline int qRound(qreal d)
1087 { return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
1089 #if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
1090 inline qint64 qRound64(double d)
1091 { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
1092 #else
1093 inline qint64 qRound64(qreal d)
1094 { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
1095 #endif
1097 template <typename T>
1098 inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; }
1099 template <typename T>
1100 inline const T &qMax(const T &a, const T &b) { if (a < b) return b; return a; }
1101 template <typename T>
1102 inline const T &qBound(const T &min, const T &val, const T &max)
1103 { return qMax(min, qMin(max, val)); }
1105 #ifdef QT3_SUPPORT
1106 typedef qint8 Q_INT8;
1107 typedef quint8 Q_UINT8;
1108 typedef qint16 Q_INT16;
1109 typedef quint16 Q_UINT16;
1110 typedef qint32 Q_INT32;
1111 typedef quint32 Q_UINT32;
1112 typedef qint64 Q_INT64;
1113 typedef quint64 Q_UINT64;
1115 typedef qint64 Q_LLONG;
1116 typedef quint64 Q_ULLONG;
1117 #if defined(Q_OS_WIN64)
1118 typedef __int64 Q_LONG; /* word up to 64 bit signed */
1119 typedef unsigned __int64 Q_ULONG; /* word up to 64 bit unsigned */
1120 #else
1121 typedef long Q_LONG; /* word up to 64 bit signed */
1122 typedef unsigned long Q_ULONG; /* word up to 64 bit unsigned */
1123 #endif
1125 # define QABS(a) qAbs(a)
1126 # define QMAX(a, b) qMax((a), (b))
1127 # define QMIN(a, b) qMin((a), (b))
1128 #endif
1131 Data stream functions are provided by many classes (defined in qdatastream.h)
1134 class QDataStream;
1136 #ifndef QT_BUILD_KEY
1137 #define QT_BUILD_KEY "unspecified"
1138 #endif
1140 #if defined(Q_WS_MAC)
1141 # ifndef QMAC_QMENUBAR_NO_EVENT
1142 # define QMAC_QMENUBAR_NO_EVENT
1143 # endif
1144 #endif
1146 #if !defined(Q_WS_QWS) && !defined(QT_NO_COP)
1147 # define QT_NO_COP
1148 #endif
1150 #if defined(Q_OS_VXWORKS)
1151 # define QT_NO_CRASHHANDLER // no popen
1152 # define QT_NO_PROCESS // no exec*, no fork
1153 # define QT_NO_LPR
1154 # define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end...
1155 # define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space
1156 # define QT_NO_QWS_MULTIPROCESS // no processes
1157 #endif
1159 # include <QtCore/qfeatures.h>
1161 #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
1163 #ifndef Q_DECL_EXPORT
1164 # if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
1165 # define Q_DECL_EXPORT __declspec(dllexport)
1166 # elif defined(QT_VISIBILITY_AVAILABLE)
1167 # define Q_DECL_EXPORT __attribute__((visibility("default")))
1168 # endif
1169 # ifndef Q_DECL_EXPORT
1170 # define Q_DECL_EXPORT
1171 # endif
1172 #endif
1173 #ifndef Q_DECL_IMPORT
1174 # if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
1175 # define Q_DECL_IMPORT __declspec(dllimport)
1176 # else
1177 # define Q_DECL_IMPORT
1178 # endif
1179 #endif
1182 Create Qt DLL if QT_DLL is defined (Windows and Symbian only)
1185 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
1186 # if defined(QT_NODLL)
1187 # undef QT_MAKEDLL
1188 # undef QT_DLL
1189 # elif defined(QT_MAKEDLL) /* create a Qt DLL library */
1190 # if defined(QT_DLL)
1191 # undef QT_DLL
1192 # endif
1193 # if defined(QT_BUILD_CORE_LIB)
1194 # define Q_CORE_EXPORT Q_DECL_EXPORT
1195 # else
1196 # define Q_CORE_EXPORT Q_DECL_IMPORT
1197 # endif
1198 # if defined(QT_BUILD_GUI_LIB)
1199 # define Q_GUI_EXPORT Q_DECL_EXPORT
1200 # else
1201 # define Q_GUI_EXPORT Q_DECL_IMPORT
1202 # endif
1203 # if defined(QT_BUILD_SQL_LIB)
1204 # define Q_SQL_EXPORT Q_DECL_EXPORT
1205 # else
1206 # define Q_SQL_EXPORT Q_DECL_IMPORT
1207 # endif
1208 # if defined(QT_BUILD_NETWORK_LIB)
1209 # define Q_NETWORK_EXPORT Q_DECL_EXPORT
1210 # else
1211 # define Q_NETWORK_EXPORT Q_DECL_IMPORT
1212 # endif
1213 # if defined(QT_BUILD_SVG_LIB)
1214 # define Q_SVG_EXPORT Q_DECL_EXPORT
1215 # else
1216 # define Q_SVG_EXPORT Q_DECL_IMPORT
1217 # endif
1218 # if defined(QT_BUILD_DECLARATIVE_LIB)
1219 # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
1220 # else
1221 # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
1222 # endif
1223 # if defined(QT_BUILD_OPENGL_LIB)
1224 # define Q_OPENGL_EXPORT Q_DECL_EXPORT
1225 # else
1226 # define Q_OPENGL_EXPORT Q_DECL_IMPORT
1227 # endif
1228 # if defined(QT_BUILD_MULTIMEDIA_LIB)
1229 # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
1230 # else
1231 # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
1232 # endif
1233 # if defined(QT_BUILD_OPENVG_LIB)
1234 # define Q_OPENVG_EXPORT Q_DECL_EXPORT
1235 # else
1236 # define Q_OPENVG_EXPORT Q_DECL_IMPORT
1237 # endif
1238 # if defined(QT_BUILD_XML_LIB)
1239 # define Q_XML_EXPORT Q_DECL_EXPORT
1240 # else
1241 # define Q_XML_EXPORT Q_DECL_IMPORT
1242 # endif
1243 # if defined(QT_BUILD_XMLPATTERNS_LIB)
1244 # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
1245 # else
1246 # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
1247 # endif
1248 # if defined(QT_BUILD_SCRIPT_LIB)
1249 # define Q_SCRIPT_EXPORT Q_DECL_EXPORT
1250 # else
1251 # define Q_SCRIPT_EXPORT Q_DECL_IMPORT
1252 # endif
1253 # if defined(QT_BUILD_SCRIPTTOOLS_LIB)
1254 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
1255 # else
1256 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
1257 # endif
1258 # if defined(QT_BUILD_CANVAS_LIB)
1259 # define Q_CANVAS_EXPORT Q_DECL_EXPORT
1260 # else
1261 # define Q_CANVAS_EXPORT Q_DECL_IMPORT
1262 # endif
1263 # if defined(QT_BUILD_COMPAT_LIB)
1264 # define Q_COMPAT_EXPORT Q_DECL_EXPORT
1265 # else
1266 # define Q_COMPAT_EXPORT Q_DECL_IMPORT
1267 # endif
1268 # define Q_TEMPLATEDLL
1269 # elif defined(QT_DLL) /* use a Qt DLL library */
1270 # define Q_CORE_EXPORT Q_DECL_IMPORT
1271 # define Q_GUI_EXPORT Q_DECL_IMPORT
1272 # define Q_SQL_EXPORT Q_DECL_IMPORT
1273 # define Q_NETWORK_EXPORT Q_DECL_IMPORT
1274 # define Q_SVG_EXPORT Q_DECL_IMPORT
1275 # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
1276 # define Q_CANVAS_EXPORT Q_DECL_IMPORT
1277 # define Q_OPENGL_EXPORT Q_DECL_IMPORT
1278 # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
1279 # define Q_OPENVG_EXPORT Q_DECL_IMPORT
1280 # define Q_XML_EXPORT Q_DECL_IMPORT
1281 # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
1282 # define Q_SCRIPT_EXPORT Q_DECL_IMPORT
1283 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
1284 # define Q_COMPAT_EXPORT Q_DECL_IMPORT
1285 # define Q_TEMPLATEDLL
1286 # endif
1287 # define Q_NO_DECLARED_NOT_DEFINED
1288 #else
1289 # if defined(Q_OS_LINUX) && defined(Q_CC_BOR)
1290 # define Q_TEMPLATEDLL
1291 # define Q_NO_DECLARED_NOT_DEFINED
1292 # endif
1293 # undef QT_MAKEDLL /* ignore these for other platforms */
1294 # undef QT_DLL
1295 #endif
1297 #if !defined(Q_CORE_EXPORT)
1298 # if defined(QT_SHARED)
1299 # define Q_CORE_EXPORT Q_DECL_EXPORT
1300 # define Q_GUI_EXPORT Q_DECL_EXPORT
1301 # define Q_SQL_EXPORT Q_DECL_EXPORT
1302 # define Q_NETWORK_EXPORT Q_DECL_EXPORT
1303 # define Q_SVG_EXPORT Q_DECL_EXPORT
1304 # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
1305 # define Q_OPENGL_EXPORT Q_DECL_EXPORT
1306 # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
1307 # define Q_OPENVG_EXPORT Q_DECL_EXPORT
1308 # define Q_XML_EXPORT Q_DECL_EXPORT
1309 # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
1310 # define Q_SCRIPT_EXPORT Q_DECL_EXPORT
1311 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
1312 # define Q_COMPAT_EXPORT Q_DECL_EXPORT
1313 # else
1314 # define Q_CORE_EXPORT
1315 # define Q_GUI_EXPORT
1316 # define Q_SQL_EXPORT
1317 # define Q_NETWORK_EXPORT
1318 # define Q_SVG_EXPORT
1319 # define Q_DECLARATIVE_EXPORT
1320 # define Q_OPENGL_EXPORT
1321 # define Q_MULTIMEDIA_EXPORT
1322 # define Q_XML_EXPORT
1323 # define Q_XMLPATTERNS_EXPORT
1324 # define Q_SCRIPT_EXPORT
1325 # define Q_SCRIPTTOOLS_EXPORT
1326 # define Q_COMPAT_EXPORT
1327 # endif
1328 #endif
1330 // Functions marked as Q_GUI_EXPORT_INLINE were exported and inlined by mistake.
1331 // Compilers like MinGW complain that the import attribute is ignored.
1332 #if defined(Q_CC_MINGW)
1333 # if defined(QT_BUILD_CORE_LIB)
1334 # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
1335 # else
1336 # define Q_CORE_EXPORT_INLINE inline
1337 # endif
1338 # if defined(QT_BUILD_GUI_LIB)
1339 # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
1340 # else
1341 # define Q_GUI_EXPORT_INLINE inline
1342 # endif
1343 #elif defined(Q_CC_RVCT)
1344 // we force RVCT not to export inlines by passing --visibility_inlines_hidden
1345 // so we need to just inline it, rather than exporting and inlining
1346 // note: this affects the contents of the DEF files (ie. these functions do not appear)
1347 # define Q_CORE_EXPORT_INLINE inline
1348 # define Q_GUI_EXPORT_INLINE inline
1349 #else
1350 # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
1351 # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
1352 #endif
1355 No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
1356 for Qt's internal unit tests. If you want slower loading times and more
1357 symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
1359 #if defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_MAKEDLL)
1360 # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
1361 #elif defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_DLL)
1362 # define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
1363 #elif defined(QT_BUILD_INTERNAL) && !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_SHARED)
1364 # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
1365 #else
1366 # define Q_AUTOTEST_EXPORT
1367 #endif
1369 inline void qt_noop() {}
1371 /* These wrap try/catch so we can switch off exceptions later.
1373 Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
1374 the exception instance in the catch block.
1375 If you can't live with those constraints, don't use these macros.
1376 Use the QT_NO_EXCEPTIONS macro to protect your code instead.
1379 #ifdef QT_BOOTSTRAPPED
1380 # define QT_NO_EXCEPTIONS
1381 #endif
1382 #if !defined(QT_NO_EXCEPTIONS) && defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN)
1383 # define QT_NO_EXCEPTIONS
1384 #endif
1386 #ifdef QT_NO_EXCEPTIONS
1387 # define QT_TRY if (true)
1388 # define QT_CATCH(A) else
1389 # define QT_THROW(A) qt_noop()
1390 # define QT_RETHROW qt_noop()
1391 #else
1392 # define QT_TRY try
1393 # define QT_CATCH(A) catch (A)
1394 # define QT_THROW(A) throw A
1395 # define QT_RETHROW throw
1396 #endif
1399 System information
1402 class QString;
1403 class Q_CORE_EXPORT QSysInfo {
1404 public:
1405 enum Sizes {
1406 WordSize = (sizeof(void *)<<3)
1409 #if defined(QT_BUILD_QMAKE)
1410 enum Endian {
1411 BigEndian,
1412 LittleEndian
1414 /* needed to bootstrap qmake */
1415 static const int ByteOrder;
1416 #elif defined(Q_BYTE_ORDER)
1417 enum Endian {
1418 BigEndian,
1419 LittleEndian
1421 # ifdef qdoc
1422 , ByteOrder = <platform-dependent>
1423 # elif Q_BYTE_ORDER == Q_BIG_ENDIAN
1424 , ByteOrder = BigEndian
1425 # elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1426 , ByteOrder = LittleEndian
1427 # else
1428 # error "Undefined byte order"
1429 # endif
1431 #else
1432 # error "Qt not configured correctly, please run configure"
1433 #endif
1434 #if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN)
1435 enum WinVersion {
1436 WV_32s = 0x0001,
1437 WV_95 = 0x0002,
1438 WV_98 = 0x0003,
1439 WV_Me = 0x0004,
1440 WV_DOS_based= 0x000f,
1442 /* codenames */
1443 WV_NT = 0x0010,
1444 WV_2000 = 0x0020,
1445 WV_XP = 0x0030,
1446 WV_2003 = 0x0040,
1447 WV_VISTA = 0x0080,
1448 WV_WINDOWS7 = 0x0090,
1449 WV_NT_based = 0x00f0,
1451 /* version numbers */
1452 WV_4_0 = WV_NT,
1453 WV_5_0 = WV_2000,
1454 WV_5_1 = WV_XP,
1455 WV_5_2 = WV_2003,
1456 WV_6_0 = WV_VISTA,
1457 WV_6_1 = WV_WINDOWS7,
1459 WV_CE = 0x0100,
1460 WV_CENET = 0x0200,
1461 WV_CE_5 = 0x0300,
1462 WV_CE_6 = 0x0400,
1463 WV_CE_based = 0x0f00
1465 static const WinVersion WindowsVersion;
1466 static WinVersion windowsVersion();
1468 #endif
1469 #ifdef Q_OS_MAC
1470 enum MacVersion {
1471 MV_Unknown = 0x0000,
1473 /* version */
1474 MV_9 = 0x0001,
1475 MV_10_0 = 0x0002,
1476 MV_10_1 = 0x0003,
1477 MV_10_2 = 0x0004,
1478 MV_10_3 = 0x0005,
1479 MV_10_4 = 0x0006,
1480 MV_10_5 = 0x0007,
1481 MV_10_6 = 0x0008,
1483 /* codenames */
1484 MV_CHEETAH = MV_10_0,
1485 MV_PUMA = MV_10_1,
1486 MV_JAGUAR = MV_10_2,
1487 MV_PANTHER = MV_10_3,
1488 MV_TIGER = MV_10_4,
1489 MV_LEOPARD = MV_10_5,
1490 MV_SNOWLEOPARD = MV_10_6
1492 static const MacVersion MacintoshVersion;
1493 #endif
1494 #ifdef Q_OS_SYMBIAN
1495 enum SymbianVersion {
1496 SV_Unknown = 0x0000,
1497 //These are the Symbian Ltd versions 9.2-9.4
1498 SV_9_2 = 10,
1499 SV_9_3 = 20,
1500 SV_9_4 = 30,
1501 //Following values are the symbian foundation versions, i.e. Symbian^1 == SV_SF_1
1502 SV_SF_1 = SV_9_4,
1503 SV_SF_2 = 40,
1504 SV_SF_3 = 50,
1505 SV_SF_4 = 60
1507 static SymbianVersion symbianVersion();
1508 enum S60Version {
1509 SV_S60_None = 0,
1510 SV_S60_Unknown = 1,
1511 SV_S60_3_1 = SV_9_2,
1512 SV_S60_3_2 = SV_9_3,
1513 SV_S60_5_0 = SV_9_4,
1514 //versions beyond 5.0 are to be confirmed - it is better to use symbian version
1515 SV_S60_5_1 = SV_SF_2,
1516 SV_S60_5_2 = SV_SF_3
1518 static S60Version s60Version();
1519 #endif
1522 Q_CORE_EXPORT const char *qVersion();
1523 Q_CORE_EXPORT bool qSharedBuild();
1525 #if defined(Q_OS_MAC)
1526 inline int qMacVersion() { return QSysInfo::MacintoshVersion; }
1527 #endif
1529 #ifdef QT3_SUPPORT
1530 inline QT3_SUPPORT bool qSysInfo(int *wordSize, bool *bigEndian)
1532 *wordSize = QSysInfo::WordSize;
1533 *bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
1534 return true;
1536 #endif
1538 #if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN)
1539 #if defined(QT3_SUPPORT)
1540 inline QT3_SUPPORT bool qt_winUnicode() { return true; }
1541 inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; }
1542 #endif
1544 // ### Qt 5: remove Win9x support macros QT_WA and QT_WA_INLINE.
1545 #define QT_WA(unicode, ansi) unicode
1546 #define QT_WA_INLINE(unicode, ansi) (unicode)
1548 #endif /* Q_WS_WIN */
1550 #ifndef Q_OUTOFLINE_TEMPLATE
1551 # define Q_OUTOFLINE_TEMPLATE
1552 #endif
1553 #ifndef Q_INLINE_TEMPLATE
1554 # define Q_INLINE_TEMPLATE inline
1555 #endif
1557 #ifndef Q_TYPENAME
1558 # define Q_TYPENAME typename
1559 #endif
1562 Avoid "unused parameter" warnings
1565 #if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT)
1566 template <typename T>
1567 inline void qUnused(T &x) { (void)x; }
1568 # define Q_UNUSED(x) qUnused(x);
1569 #else
1570 # define Q_UNUSED(x) (void)x;
1571 #endif
1574 Debugging and error handling
1578 On Symbian we do not know beforehand whether we are compiling in
1579 release or debug mode, so check the Symbian build define here,
1580 and set the QT_NO_DEBUG define appropriately.
1582 #if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG)
1583 # define QT_NO_DEBUG
1584 #endif
1586 #if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
1587 # define QT_DEBUG
1588 #endif
1590 #ifndef qPrintable
1591 # define qPrintable(string) (string).toLocal8Bit().constData()
1592 #endif
1594 Q_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */
1595 #if defined(Q_CC_GNU) && !defined(__INSURE__)
1596 __attribute__ ((format (printf, 1, 2)))
1597 #endif
1600 Q_CORE_EXPORT void qWarning(const char *, ...) /* print warning message */
1601 #if defined(Q_CC_GNU) && !defined(__INSURE__)
1602 __attribute__ ((format (printf, 1, 2)))
1603 #endif
1606 class QString;
1607 Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
1608 Q_CORE_EXPORT void qCritical(const char *, ...) /* print critical message */
1609 #if defined(Q_CC_GNU) && !defined(__INSURE__)
1610 __attribute__ ((format (printf, 1, 2)))
1611 #endif
1613 Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */
1614 #if defined(Q_CC_GNU) && !defined(__INSURE__)
1615 __attribute__ ((format (printf, 1, 2)))
1616 #endif
1619 #ifdef QT3_SUPPORT
1620 Q_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1);
1621 #endif /* QT3_SUPPORT */
1622 Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
1623 Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
1625 #if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
1626 #define QT_NO_DEBUG_STREAM
1627 #endif
1630 Forward declarations only.
1632 In order to use the qDebug() stream, you must #include<QDebug>
1634 class QDebug;
1635 class QNoDebug;
1636 #ifndef QT_NO_DEBUG_STREAM
1637 Q_CORE_EXPORT_INLINE QDebug qDebug();
1638 Q_CORE_EXPORT_INLINE QDebug qWarning();
1639 Q_CORE_EXPORT_INLINE QDebug qCritical();
1640 #else
1641 inline QNoDebug qDebug();
1642 #endif
1644 #define QT_NO_QDEBUG_MACRO while (false) qDebug
1645 #ifdef QT_NO_DEBUG_OUTPUT
1646 # define qDebug QT_NO_QDEBUG_MACRO
1647 #endif
1648 #define QT_NO_QWARNING_MACRO while (false) qWarning
1649 #ifdef QT_NO_WARNING_OUTPUT
1650 # define qWarning QT_NO_QWARNING_MACRO
1651 #endif
1654 Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
1656 #if !defined(Q_ASSERT)
1657 # ifndef QT_NO_DEBUG
1658 # define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
1659 # else
1660 # define Q_ASSERT(cond) qt_noop()
1661 # endif
1662 #endif
1664 #if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG)
1665 #define QT_NO_PAINT_DEBUG
1666 #endif
1668 Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
1670 #if !defined(Q_ASSERT_X)
1671 # ifndef QT_NO_DEBUG
1672 # define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
1673 # else
1674 # define Q_ASSERT_X(cond, where, what) qt_noop()
1675 # endif
1676 #endif
1678 Q_CORE_EXPORT void qt_check_pointer(const char *, int);
1680 #ifndef QT_NO_EXCEPTIONS
1681 Q_CORE_EXPORT void qBadAlloc();
1682 #endif
1684 #ifdef QT_NO_EXCEPTIONS
1685 # if defined(QT_NO_DEBUG)
1686 # define Q_CHECK_PTR(p) qt_noop();
1687 # else
1688 # define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
1689 # endif
1690 #else
1691 # define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
1692 #endif
1694 template <typename T>
1695 inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
1697 #if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
1698 # define Q_FUNC_INFO __PRETTY_FUNCTION__
1699 #elif defined(_MSC_VER)
1700 /* MSVC 2002 doesn't have __FUNCSIG__ nor can it handle QT_STRINGIFY. */
1701 # if _MSC_VER <= 1300
1702 # define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1703 # else
1704 # define Q_FUNC_INFO __FUNCSIG__
1705 # endif
1706 #else
1707 # if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN)
1708 # define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1709 # else
1710 /* These two macros makes it possible to turn the builtin line expander into a
1711 * string literal. */
1712 # define QT_STRINGIFY2(x) #x
1713 # define QT_STRINGIFY(x) QT_STRINGIFY2(x)
1714 # define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
1715 # endif
1716 /* The MIPSpro and RVCT compilers postpones macro expansion,
1717 and therefore macros must be in scope when being used. */
1718 # if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT) && !defined(Q_CC_NOKIAX86)
1719 # undef QT_STRINGIFY2
1720 # undef QT_STRINGIFY
1721 # endif
1722 #endif
1724 enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg };
1726 Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf);
1728 typedef void (*QtMsgHandler)(QtMsgType, const char *);
1729 Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
1731 #ifdef QT3_SUPPORT
1732 inline QT3_SUPPORT void qSuppressObsoleteWarnings(bool = true) {}
1733 inline QT3_SUPPORT void qObsolete(const char *, const char * = 0, const char * = 0) {}
1734 #endif
1736 #if defined(QT_NO_THREAD)
1738 template <typename T>
1739 class QGlobalStatic
1741 public:
1742 T *pointer;
1743 inline QGlobalStatic(T *p) : pointer(p) { }
1744 inline ~QGlobalStatic() { pointer = 0; }
1747 #define Q_GLOBAL_STATIC(TYPE, NAME) \
1748 static TYPE *NAME() \
1750 static TYPE this_##NAME; \
1751 static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
1752 return global_##NAME.pointer; \
1755 #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1756 static TYPE *NAME() \
1758 static TYPE this_##NAME ARGS; \
1759 static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
1760 return global_##NAME.pointer; \
1763 #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1764 static TYPE *NAME() \
1766 static TYPE this_##NAME; \
1767 static QGlobalStatic<TYPE > global_##NAME(0); \
1768 if (!global_##NAME.pointer) { \
1769 TYPE *x = global_##NAME.pointer = &this_##NAME; \
1770 INITIALIZER; \
1772 return global_##NAME.pointer; \
1775 #else
1777 // forward declaration, since qatomic.h needs qglobal.h
1778 template <typename T> class QBasicAtomicPointer;
1780 // POD for Q_GLOBAL_STATIC
1781 template <typename T>
1782 class QGlobalStatic
1784 public:
1785 QBasicAtomicPointer<T> pointer;
1786 bool destroyed;
1789 // Created as a function-local static to delete a QGlobalStatic<T>
1790 template <typename T>
1791 class QGlobalStaticDeleter
1793 public:
1794 QGlobalStatic<T> &globalStatic;
1795 QGlobalStaticDeleter(QGlobalStatic<T> &_globalStatic)
1796 : globalStatic(_globalStatic)
1799 inline ~QGlobalStaticDeleter()
1801 delete globalStatic.pointer;
1802 globalStatic.pointer = 0;
1803 globalStatic.destroyed = true;
1807 #define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
1808 static QGlobalStatic<TYPE > this_##NAME = { Q_BASIC_ATOMIC_INITIALIZER(0), false }
1810 #define Q_GLOBAL_STATIC(TYPE, NAME) \
1811 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1812 static TYPE *NAME() \
1814 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1815 TYPE *x = new TYPE; \
1816 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
1817 delete x; \
1818 else \
1819 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1821 return this_##NAME.pointer; \
1824 #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1825 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1826 static TYPE *NAME() \
1828 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1829 TYPE *x = new TYPE ARGS; \
1830 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
1831 delete x; \
1832 else \
1833 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1835 return this_##NAME.pointer; \
1838 #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1839 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1840 static TYPE *NAME() \
1842 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1843 QScopedPointer<TYPE > x(new TYPE); \
1844 INITIALIZER; \
1845 if (this_##NAME.pointer.testAndSetOrdered(0, x.data())) { \
1846 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1847 x.take(); \
1850 return this_##NAME.pointer; \
1853 #endif
1855 class QBool
1857 bool b;
1859 public:
1860 inline explicit QBool(bool B) : b(B) {}
1861 inline operator const void *() const
1862 { return b ? static_cast<const void *>(this) : static_cast<const void *>(0); }
1865 inline bool operator==(QBool b1, bool b2) { return !b1 == !b2; }
1866 inline bool operator==(bool b1, QBool b2) { return !b1 == !b2; }
1867 inline bool operator==(QBool b1, QBool b2) { return !b1 == !b2; }
1868 inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; }
1869 inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; }
1870 inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; }
1872 static inline bool qFuzzyCompare(double p1, double p2)
1874 return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
1877 static inline bool qFuzzyCompare(float p1, float p2)
1879 return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
1883 \internal
1885 static inline bool qFuzzyIsNull(double d)
1887 return qAbs(d) <= 0.000000000001;
1891 \internal
1893 static inline bool qFuzzyIsNull(float f)
1895 return qAbs(f) <= 0.00001f;
1899 This function tests a double for a null value. It doesn't
1900 check whether the actual value is 0 or close to 0, but whether
1901 it is binary 0.
1903 static inline bool qIsNull(double d)
1905 union U {
1906 double d;
1907 quint64 u;
1909 U val;
1910 val.d = d;
1911 return val.u == quint64(0);
1915 This function tests a float for a null value. It doesn't
1916 check whether the actual value is 0 or close to 0, but whether
1917 it is binary 0.
1919 static inline bool qIsNull(float f)
1921 union U {
1922 float f;
1923 quint32 u;
1925 U val;
1926 val.f = f;
1927 return val.u == 0u;
1931 Compilers which follow outdated template instantiation rules
1932 require a class to have a comparison operator to exist when
1933 a QList of this type is instantiated. It's not actually
1934 used in the list, though. Hence the dummy implementation.
1935 Just in case other code relies on it we better trigger a warning
1936 mandating a real implementation.
1939 #ifdef Q_FULL_TEMPLATE_INSTANTIATION
1940 # define Q_DUMMY_COMPARISON_OPERATOR(C) \
1941 bool operator==(const C&) const { \
1942 qWarning(#C"::operator==(const "#C"&) was called"); \
1943 return false; \
1945 #else
1946 # define Q_DUMMY_COMPARISON_OPERATOR(C)
1947 #endif
1951 QTypeInfo - type trait functionality
1952 qIsDetached - data sharing functionality
1955 #ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
1958 The catch-all template.
1961 template <typename T> inline bool qIsDetached(T &) { return true; }
1963 template <typename T>
1964 class QTypeInfo
1966 public:
1967 enum {
1968 isPointer = false,
1969 isComplex = true,
1970 isStatic = true,
1971 isLarge = (sizeof(T)>sizeof(void*)),
1972 isDummy = false
1976 template <typename T>
1977 class QTypeInfo<T*>
1979 public:
1980 enum {
1981 isPointer = true,
1982 isComplex = false,
1983 isStatic = false,
1984 isLarge = false,
1985 isDummy = false
1989 #else
1991 template <typename T> char QTypeInfoHelper(T*(*)());
1992 void* QTypeInfoHelper(...);
1994 template <typename T> inline bool qIsDetached(T &) { return true; }
1996 template <typename T>
1997 class QTypeInfo
1999 public:
2000 enum {
2001 isPointer = (1 == sizeof(QTypeInfoHelper((T(*)())0))),
2002 isComplex = !isPointer,
2003 isStatic = !isPointer,
2004 isLarge = (sizeof(T)>sizeof(void*)),
2005 isDummy = false
2009 #endif /* QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION */
2012 Specialize a specific type with:
2014 Q_DECLARE_TYPEINFO(type, flags);
2016 where 'type' is the name of the type to specialize and 'flags' is
2017 logically-OR'ed combination of the flags below.
2019 enum { /* TYPEINFO flags */
2020 Q_COMPLEX_TYPE = 0,
2021 Q_PRIMITIVE_TYPE = 0x1,
2022 Q_STATIC_TYPE = 0,
2023 Q_MOVABLE_TYPE = 0x2,
2024 Q_DUMMY_TYPE = 0x4
2027 #define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
2028 template <> \
2029 class QTypeInfo<TYPE > \
2031 public: \
2032 enum { \
2033 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \
2034 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
2035 isLarge = (sizeof(TYPE)>sizeof(void*)), \
2036 isPointer = false, \
2037 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) \
2038 }; \
2039 static inline const char *name() { return #TYPE; } \
2042 template <typename T>
2043 inline void qSwap(T &value1, T &value2)
2045 const T t = value1;
2046 value1 = value2;
2047 value2 = t;
2051 Specialize a shared type with:
2053 Q_DECLARE_SHARED(type);
2055 where 'type' is the name of the type to specialize. NOTE: shared
2056 types must declare a 'bool isDetached(void) const;' member for this
2057 to work.
2059 #define Q_DECLARE_SHARED(TYPE) \
2060 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
2061 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
2063 qSwap(value1.data_ptr(), value2.data_ptr()); \
2067 QTypeInfo primitive specializations
2069 Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE);
2070 Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE);
2071 Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE);
2072 Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE);
2073 Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE);
2074 Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE);
2075 Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE);
2076 Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE);
2077 Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE);
2078 Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE);
2079 Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE);
2080 Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE);
2081 Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE);
2082 Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
2083 #ifndef Q_OS_DARWIN
2084 Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
2085 #endif
2088 These functions make it possible to use standard C++ functions with
2089 a similar name from Qt header files (especially template classes).
2091 Q_CORE_EXPORT void *qMalloc(size_t size);
2092 Q_CORE_EXPORT void qFree(void *ptr);
2093 Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size);
2094 Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment);
2095 Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment);
2096 Q_CORE_EXPORT void qFreeAligned(void *ptr);
2097 Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
2098 Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
2102 Avoid some particularly useless warnings from some stupid compilers.
2103 To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
2104 the line "#define QT_NO_WARNINGS".
2106 #if !defined(QT_CC_WARNINGS)
2107 # define QT_NO_WARNINGS
2108 #endif
2109 #if defined(QT_NO_WARNINGS)
2110 # if defined(Q_CC_MSVC)
2111 # pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */
2112 # pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */
2113 # pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
2114 # pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */
2115 # pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
2116 # pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
2117 # pragma warning(disable: 4706) /* assignment within conditional expression */
2118 # pragma warning(disable: 4786) /* truncating debug info after 255 characters */
2119 # pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */
2120 # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
2121 # pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
2122 # pragma warning(disable: 4710) /* function not inlined */
2123 # pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */
2124 # if _MSC_VER < 1300
2125 # pragma warning(disable: 4284) /* return type for 'type1::operator ->' is 'type2 *' */
2126 /* (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) */
2127 # endif
2128 # elif defined(Q_CC_BOR)
2129 # pragma option -w-inl
2130 # pragma option -w-aus
2131 # pragma warn -inl
2132 # pragma warn -pia
2133 # pragma warn -ccc
2134 # pragma warn -rch
2135 # pragma warn -sig
2136 # endif
2137 #endif
2139 class Q_CORE_EXPORT QFlag
2141 int i;
2142 public:
2143 inline QFlag(int i);
2144 inline operator int() const { return i; }
2147 inline QFlag::QFlag(int ai) : i(ai) {}
2149 class Q_CORE_EXPORT QIncompatibleFlag
2151 int i;
2152 public:
2153 inline explicit QIncompatibleFlag(int i);
2154 inline operator int() const { return i; }
2157 inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
2160 #ifndef Q_NO_TYPESAFE_FLAGS
2162 template<typename Enum>
2163 class QFlags
2165 typedef void **Zero;
2166 int i;
2167 public:
2168 typedef Enum enum_type;
2169 inline QFlags(const QFlags &f) : i(f.i) {}
2170 inline QFlags(Enum f) : i(f) {}
2171 inline QFlags(Zero = 0) : i(0) {}
2172 inline QFlags(QFlag f) : i(f) {}
2174 inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; }
2175 inline QFlags &operator&=(int mask) { i &= mask; return *this; }
2176 inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
2177 inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
2178 inline QFlags &operator|=(Enum f) { i |= f; return *this; }
2179 inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
2180 inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
2182 inline operator int() const { return i; }
2184 inline QFlags operator|(QFlags f) const { QFlags g; g.i = i | f.i; return g; }
2185 inline QFlags operator|(Enum f) const { QFlags g; g.i = i | f; return g; }
2186 inline QFlags operator^(QFlags f) const { QFlags g; g.i = i ^ f.i; return g; }
2187 inline QFlags operator^(Enum f) const { QFlags g; g.i = i ^ f; return g; }
2188 inline QFlags operator&(int mask) const { QFlags g; g.i = i & mask; return g; }
2189 inline QFlags operator&(uint mask) const { QFlags g; g.i = i & mask; return g; }
2190 inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; }
2191 inline QFlags operator~() const { QFlags g; g.i = ~i; return g; }
2193 inline bool operator!() const { return !i; }
2195 inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
2198 #define Q_DECLARE_FLAGS(Flags, Enum)\
2199 typedef QFlags<Enum> Flags;
2201 #if defined Q_CC_MSVC && _MSC_VER < 1300
2202 # define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
2203 #else
2204 # define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
2205 inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
2206 { return QIncompatibleFlag(int(f1) | f2); }
2207 #endif
2209 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
2210 inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
2211 { return QFlags<Flags::enum_type>(f1) | f2; } \
2212 inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
2213 { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
2216 #else /* Q_NO_TYPESAFE_FLAGS */
2218 #define Q_DECLARE_FLAGS(Flags, Enum)\
2219 typedef uint Flags;
2220 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
2222 #endif /* Q_NO_TYPESAFE_FLAGS */
2224 #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
2225 /* make use of typeof-extension */
2226 template <typename T>
2227 class QForeachContainer {
2228 public:
2229 inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
2230 const T c;
2231 int brk;
2232 typename T::const_iterator i, e;
2235 #define Q_FOREACH(variable, container) \
2236 for (QForeachContainer<__typeof__(container)> _container_(container); \
2237 !_container_.brk && _container_.i != _container_.e; \
2238 __extension__ ({ ++_container_.brk; ++_container_.i; })) \
2239 for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
2241 #else
2243 struct QForeachContainerBase {};
2245 template <typename T>
2246 class QForeachContainer : public QForeachContainerBase {
2247 public:
2248 inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){};
2249 const T c;
2250 mutable int brk;
2251 mutable typename T::const_iterator i, e;
2252 inline bool condition() const { return (!brk++ && i != e); }
2255 template <typename T> inline T *qForeachPointer(const T &) { return 0; }
2257 template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t)
2258 { return QForeachContainer<T>(t); }
2260 template <typename T>
2261 inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *)
2262 { return static_cast<const QForeachContainer<T> *>(base); }
2264 #if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS)
2266 Proper for-scoping in VC++6 and MIPSpro CC
2268 # define Q_FOREACH(variable,container) \
2269 if(0){}else \
2270 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2271 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
2272 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
2273 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
2274 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
2275 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
2277 #elif defined(Q_CC_DIAB)
2278 // VxWorks DIAB generates unresolvable symbols, if container is a function call
2279 # define Q_FOREACH(variable,container) \
2280 if(0){}else \
2281 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2282 qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \
2283 ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \
2284 for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \
2285 qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \
2286 --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk)
2288 #else
2289 # define Q_FOREACH(variable, container) \
2290 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2291 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
2292 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
2293 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
2294 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
2295 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
2296 #endif // MSVC6 || MIPSpro
2298 #endif
2300 #define Q_FOREVER for(;;)
2301 #ifndef QT_NO_KEYWORDS
2302 # ifndef foreach
2303 # define foreach Q_FOREACH
2304 # endif
2305 # ifndef forever
2306 # define forever Q_FOREVER
2307 # endif
2308 #endif
2310 #if 0
2311 /* tell gcc to use its built-in methods for some common functions */
2312 #if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
2313 # define qMemCopy __builtin_memcpy
2314 # define qMemSet __builtin_memset
2315 #endif
2316 #endif
2318 template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
2319 template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
2321 #define Q_DECLARE_PRIVATE(Class) \
2322 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
2323 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
2324 friend class Class##Private;
2326 #define Q_DECLARE_PRIVATE_D(Dptr, Class) \
2327 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(Dptr); } \
2328 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(Dptr); } \
2329 friend class Class##Private;
2331 #define Q_DECLARE_PUBLIC(Class) \
2332 inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
2333 inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
2334 friend class Class;
2336 #define Q_D(Class) Class##Private * const d = d_func()
2337 #define Q_Q(Class) Class * const q = q_func()
2339 #define QT_TR_NOOP(x) (x)
2340 #define QT_TR_NOOP_UTF8(x) (x)
2341 #define QT_TRANSLATE_NOOP(scope, x) (x)
2342 #define QT_TRANSLATE_NOOP_UTF8(scope, x) (x)
2343 #define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
2344 #define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
2346 #ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
2348 // Defined in qcoreapplication.cpp
2349 // The better name qTrId() is reserved for an upcoming function which would
2350 // return a much more powerful QStringFormatter instead of a QString.
2351 Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
2353 #define QT_TRID_NOOP(id) id
2355 #endif // QT_NO_TRANSLATION
2357 #define QDOC_PROPERTY(text)
2360 When RTTI is not available, define this macro to force any uses of
2361 dynamic_cast to cause a compile failure.
2364 #ifdef QT_NO_DYNAMIC_CAST
2365 # define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
2367 template<typename T, typename X>
2368 T qt_dynamic_cast_check(X, T* = 0)
2369 { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
2370 #endif
2373 Some classes do not permit copies to be made of an object. These
2374 classes contains a private copy constructor and assignment
2375 operator to disable copying (the compiler gives an error message).
2377 #define Q_DISABLE_COPY(Class) \
2378 Class(const Class &); \
2379 Class &operator=(const Class &);
2381 class QByteArray;
2382 Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
2383 Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
2385 inline int qIntCast(double f) { return int(f); }
2386 inline int qIntCast(float f) { return int(f); }
2389 Reentrant versions of basic rand() functions for random number generation
2391 Q_CORE_EXPORT void qsrand(uint seed);
2392 Q_CORE_EXPORT int qrand();
2395 Compat functions that were generated by configure
2397 #ifdef QT3_SUPPORT
2398 #ifndef QT_PRODUCT_LICENSEE
2399 # define QT_PRODUCT_LICENSEE QLibraryInfo::licensee()
2400 #endif
2401 #ifndef QT_PRODUCT_LICENSE
2402 # define QT_PRODUCT_LICENSE QLibraryInfo::licensedProducts()
2403 #endif
2404 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPath();
2405 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathDocs();
2406 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathHeaders();
2407 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathLibs();
2408 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathBins();
2409 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathPlugins();
2410 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathData();
2411 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations();
2412 QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
2413 #endif
2415 #if defined(Q_OS_SYMBIAN)
2417 #ifdef SYMBIAN_GRAPHICS_USE_GCE
2418 //RWsPointerCursor is fixed, so don't use low performance sprites
2419 #define Q_SYMBIAN_FIXED_POINTER_CURSORS
2420 #define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
2421 //enabling new graphics resources
2422 #define QT_SYMBIAN_SUPPORTS_SGIMAGE
2423 #define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
2425 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
2426 #define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
2427 #endif
2428 #endif
2431 //Symbian does not support data imports from a DLL
2432 #define Q_NO_DATA_RELOCATION
2434 QT_END_NAMESPACE
2435 // forward declare std::exception
2436 #ifdef __cplusplus
2437 namespace std { class exception; }
2438 #endif
2439 QT_BEGIN_NAMESPACE
2440 Q_CORE_EXPORT void qt_symbian_throwIfError(int error);
2441 Q_CORE_EXPORT void qt_symbian_exception2LeaveL(const std::exception& ex);
2442 Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
2444 #define QT_TRAP_THROWING(_f) \
2446 TInt ____error; \
2447 TRAP(____error, _f); \
2448 qt_symbian_throwIfError(____error); \
2451 #define QT_TRYCATCH_ERROR(_err, _f) \
2453 _err = KErrNone; \
2454 try { \
2455 _f; \
2456 } catch (const std::exception &____ex) { \
2457 _err = qt_symbian_exception2Error(____ex); \
2461 #define QT_TRYCATCH_LEAVING(_f) \
2463 TInt ____err; \
2464 QT_TRYCATCH_ERROR(____err, _f) \
2465 User::LeaveIfError(____err); \
2467 #endif
2471 This gives us the possibility to check which modules the user can
2472 use. These are purely compile time checks and will generate no code.
2475 /* Qt modules */
2476 #define QT_MODULE_CORE 0x00001
2477 #define QT_MODULE_GUI 0x00002
2478 #define QT_MODULE_NETWORK 0x00004
2479 #define QT_MODULE_OPENGL 0x00008
2480 #define QT_MODULE_SQL 0x00010
2481 #define QT_MODULE_XML 0x00020
2482 #define QT_MODULE_QT3SUPPORTLIGHT 0x00040
2483 #define QT_MODULE_QT3SUPPORT 0x00080
2484 #define QT_MODULE_SVG 0x00100
2485 #define QT_MODULE_ACTIVEQT 0x00200
2486 #define QT_MODULE_GRAPHICSVIEW 0x00400
2487 #define QT_MODULE_SCRIPT 0x00800
2488 #define QT_MODULE_XMLPATTERNS 0x01000
2489 #define QT_MODULE_HELP 0x02000
2490 #define QT_MODULE_TEST 0x04000
2491 #define QT_MODULE_DBUS 0x08000
2492 #define QT_MODULE_SCRIPTTOOLS 0x10000
2493 #define QT_MODULE_OPENVG 0x20000
2494 #define QT_MODULE_MULTIMEDIA 0x40000
2495 #define QT_MODULE_DECLARATIVE 0x80000
2497 /* Qt editions */
2498 #define QT_EDITION_CONSOLE (QT_MODULE_CORE \
2499 | QT_MODULE_NETWORK \
2500 | QT_MODULE_SQL \
2501 | QT_MODULE_SCRIPT \
2502 | QT_MODULE_MULTIMEDIA \
2503 | QT_MODULE_XML \
2504 | QT_MODULE_XMLPATTERNS \
2505 | QT_MODULE_TEST \
2506 | QT_MODULE_DBUS)
2507 #define QT_EDITION_DESKTOPLIGHT (QT_MODULE_CORE \
2508 | QT_MODULE_GUI \
2509 | QT_MODULE_QT3SUPPORTLIGHT \
2510 | QT_MODULE_TEST \
2511 | QT_MODULE_DBUS)
2512 #define QT_EDITION_OPENSOURCE (QT_MODULE_CORE \
2513 | QT_MODULE_GUI \
2514 | QT_MODULE_NETWORK \
2515 | QT_MODULE_OPENGL \
2516 | QT_MODULE_OPENVG \
2517 | QT_MODULE_SQL \
2518 | QT_MODULE_MULTIMEDIA \
2519 | QT_MODULE_XML \
2520 | QT_MODULE_XMLPATTERNS \
2521 | QT_MODULE_SCRIPT \
2522 | QT_MODULE_SCRIPTTOOLS \
2523 | QT_MODULE_QT3SUPPORTLIGHT \
2524 | QT_MODULE_QT3SUPPORT \
2525 | QT_MODULE_SVG \
2526 | QT_MODULE_DECLARATIVE \
2527 | QT_MODULE_GRAPHICSVIEW \
2528 | QT_MODULE_HELP \
2529 | QT_MODULE_TEST \
2530 | QT_MODULE_DBUS \
2531 | QT_MODULE_ACTIVEQT)
2532 #define QT_EDITION_DESKTOP (QT_EDITION_OPENSOURCE)
2533 #define QT_EDITION_UNIVERSAL QT_EDITION_DESKTOP
2534 #define QT_EDITION_ACADEMIC QT_EDITION_DESKTOP
2535 #define QT_EDITION_EDUCATIONAL QT_EDITION_DESKTOP
2536 #define QT_EDITION_EVALUATION QT_EDITION_DESKTOP
2538 /* Determine which modules can be used */
2539 #ifndef QT_EDITION
2540 # ifdef QT_BUILD_QMAKE
2541 # define QT_EDITION QT_EDITION_DESKTOP
2542 # else
2543 # error "Qt not configured correctly, please run configure"
2544 # endif
2545 #endif
2547 #define QT_LICENSED_MODULE(x) \
2548 enum QtValidLicenseFor##x##Module { Licensed##x = true };
2550 /* qdoc is really unhappy with the following block of preprocessor checks,
2551 making it difficult to document classes properly after this point. */
2553 #if (QT_EDITION & QT_MODULE_CORE)
2554 QT_LICENSED_MODULE(Core)
2555 #endif
2556 #if (QT_EDITION & QT_MODULE_GUI)
2557 QT_LICENSED_MODULE(Gui)
2558 #endif
2559 #if (QT_EDITION & QT_MODULE_NETWORK)
2560 QT_LICENSED_MODULE(Network)
2561 #endif
2562 #if (QT_EDITION & QT_MODULE_OPENGL)
2563 QT_LICENSED_MODULE(OpenGL)
2564 #endif
2565 #if (QT_EDITION & QT_MODULE_OPENVG)
2566 QT_LICENSED_MODULE(OpenVG)
2567 #endif
2568 #if (QT_EDITION & QT_MODULE_SQL)
2569 QT_LICENSED_MODULE(Sql)
2570 #endif
2571 #if (QT_EDITION & QT_MODULE_MULTIMEDIA)
2572 QT_LICENSED_MODULE(Multimedia)
2573 #endif
2574 #if (QT_EDITION & QT_MODULE_XML)
2575 QT_LICENSED_MODULE(Xml)
2576 #endif
2577 #if (QT_EDITION & QT_MODULE_XMLPATTERNS)
2578 QT_LICENSED_MODULE(XmlPatterns)
2579 #endif
2580 #if (QT_EDITION & QT_MODULE_HELP)
2581 QT_LICENSED_MODULE(Help)
2582 #endif
2583 #if (QT_EDITION & QT_MODULE_SCRIPT) || defined(QT_BUILD_QMAKE)
2584 QT_LICENSED_MODULE(Script)
2585 #endif
2586 #if (QT_EDITION & QT_MODULE_SCRIPTTOOLS)
2587 QT_LICENSED_MODULE(ScriptTools)
2588 #endif
2589 #if (QT_EDITION & QT_MODULE_QT3SUPPORTLIGHT)
2590 QT_LICENSED_MODULE(Qt3SupportLight)
2591 #endif
2592 #if (QT_EDITION & QT_MODULE_QT3SUPPORT)
2593 QT_LICENSED_MODULE(Qt3Support)
2594 #endif
2595 #if (QT_EDITION & QT_MODULE_SVG)
2596 QT_LICENSED_MODULE(Svg)
2597 #endif
2598 #if (QT_EDITION & QT_MODULE_DECLARATIVE)
2599 QT_LICENSED_MODULE(Declarative)
2600 #endif
2601 #if (QT_EDITION & QT_MODULE_ACTIVEQT)
2602 QT_LICENSED_MODULE(ActiveQt)
2603 #endif
2604 #if (QT_EDITION & QT_MODULE_TEST)
2605 QT_LICENSED_MODULE(Test)
2606 #endif
2607 #if (QT_EDITION & QT_MODULE_DBUS)
2608 QT_LICENSED_MODULE(DBus)
2609 #endif
2611 #define QT_MODULE(x) \
2612 typedef QtValidLicenseFor##x##Module Qt##x##Module;
2614 #ifdef QT_NO_CONCURRENT
2615 # define QT_NO_QFUTURE
2616 #endif
2618 // MSVC 6.0 and MSVC .NET 2002, can`t handle the map(), etc templates,
2619 // but the QFuture class compiles.
2620 #if (defined(Q_CC_MSVC) && _MSC_VER <= 1300)
2621 # define QT_NO_CONCURRENT
2622 #endif
2624 // gcc 3 version has problems with some of the
2625 // map/filter overloads.
2626 #if defined(Q_CC_GNU) && (__GNUC__ < 4)
2627 # define QT_NO_CONCURRENT_MAP
2628 # define QT_NO_CONCURRENT_FILTER
2629 #endif
2631 #ifdef Q_OS_QNX
2632 // QNX doesn't have SYSV style shared memory. Multiprocess QWS apps,
2633 // shared fonts and QSystemSemaphore + QSharedMemory are not available
2634 # define QT_NO_QWS_MULTIPROCESS
2635 # define QT_NO_QWS_SHARE_FONTS
2636 # define QT_NO_SYSTEMSEMAPHORE
2637 # define QT_NO_SHAREDMEMORY
2638 // QNX currently doesn't support forking in a thread, so disable QProcess
2639 # define QT_NO_PROCESS
2640 #endif
2642 QT_END_NAMESPACE
2643 QT_END_HEADER
2645 #endif /* __cplusplus */
2647 #endif /* QGLOBAL_H */