QtBase  v6.3.1
qglobal.c
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2017 Intel Corporation.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #include <QtCore/qglobal.h>
30 
31 #if __has_include(<stdbool.h>) || __STDC_VERSION__ >= 199901L
32 # include <stdbool.h>
33 #else
34 # undef true
35 # define true 1
36 # undef false
37 # define false 0
38 #endif
39 
40 #ifdef Q_COMPILER_THREAD_LOCAL
41 # include <threads.h>
42 #endif
43 
44 /*
45  * Certain features of qglobal.h must work in C mode too. We test that
46  * everything works.
47  */
48 
49 /* Types and Q_UNUSED */
51 {
52  qint8 s8;
53  qint16 s16;
54  qint32 s32;
55  qint64 s64;
56  qlonglong sll;
57  Q_UNUSED(s8); Q_UNUSED(s16); Q_UNUSED(s32); Q_UNUSED(s64); Q_UNUSED(sll);
58 
59  quint8 u8;
60  quint16 u16;
61  quint32 u32;
62  quint64 u64;
63  qulonglong ull;
65 
66  uchar uc;
67  ushort us;
68  uint ui;
69  ulong ul;
70  Q_UNUSED(uc); Q_UNUSED(us); Q_UNUSED(ui); Q_UNUSED(ul);
71 
72  qreal qr;
73  Q_UNUSED(qr);
74 
75  qsizetype qs;
76  qptrdiff qp;
77  qintptr qip;
78  quintptr qup;
79  Q_UNUSED(qs); Q_UNUSED(qp); Q_UNUSED(qip); Q_UNUSED(qup);
80 }
81 
82 /* Qt version */
84 {
85  return QT_VERSION;
86 }
87 
89 {
90 #if !defined(QT_NAMESPACE)
91  return qVersion();
92 #else
93  return NULL;
94 #endif
95 }
96 
97 /* Static assertion */
100 Q_STATIC_ASSERT_X(true, "Message");
101 Q_STATIC_ASSERT_X(1, "Message");
102 
104 Q_STATIC_ASSERT(!0);
105 
107 Q_STATIC_ASSERT(!!1);
108 
109 #ifdef __COUNTER__
110 // if the compiler supports __COUNTER__, multiple
111 // Q_STATIC_ASSERT's on a single line should compile:
112 Q_STATIC_ASSERT(true); Q_STATIC_ASSERT_X(!false, "");
113 #endif // __COUNTER__
114 
115 #ifdef Q_COMPILER_THREAD_LOCAL
116 static thread_local int gt_var;
117 void thread_local_test()
118 {
119  static thread_local int t_var;
120  t_var = gt_var;
121  Q_UNUSED(t_var);
122 }
123 #endif
124 
#define NULL
Definition: ftobjs.h:61
#define Q_DECL_NOEXCEPT
int tst_QtVersion()
Definition: qglobal.c:83
Q_STATIC_ASSERT_X(true, "Message")
void tst_GlobalTypes()
Definition: qglobal.c:50
const char * tst_qVersion() Q_DECL_NOEXCEPT
Definition: qglobal.c:88
Q_STATIC_ASSERT(true)
unsigned int quint32
Definition: qglobal.h:288
#define QT_VERSION
Definition: qglobal.h:58
short qint16
Definition: qglobal.h:285
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
Definition: qglobal.h:332
unsigned short quint16
Definition: qglobal.h:286
size_t quintptr
Definition: qglobal.h:310
int qint32
Definition: qglobal.h:287
unsigned long ulong
Definition: qglobal.h:335
ptrdiff_t qptrdiff
Definition: qglobal.h:307
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
quint64 qulonglong
Definition: qglobal.h:302
unsigned long long quint64
Definition: qglobal.h:299
ptrdiff_t qsizetype
Definition: qglobal.h:308
unsigned int uint
Definition: qglobal.h:334
long long qint64
Definition: qglobal.h:298
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char * qVersion(void) Q_DECL_NOEXCEPT
unsigned short ushort
Definition: qglobal.h:333
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition: qglobal.h:283
unsigned char quint8
Definition: qglobal.h:284
qint64 qlonglong
Definition: qglobal.h:301
ptrdiff_t qintptr
Definition: qglobal.h:309
#define s8
Q_UNUSED(salary)
[21]
UINT32_TYPE u32
Definition: sqlite3.c:13904
sqlite_uint64 u64
Definition: sqlite3.c:13903
UINT16_TYPE u16
Definition: sqlite3.c:13905
UINT8_TYPE u8
Definition: sqlite3.c:13907