QP/C
7.0.1
Real-Time Embedded Framework
qassert.h
Go to the documentation of this file.
1
/*============================================================================
2
* QP/C Real-Time Embedded Framework (RTEF)
3
* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
4
*
5
* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
6
*
7
* This software is dual-licensed under the terms of the open source GNU
8
* General Public License version 3 (or any later version), or alternatively,
9
* under the terms of one of the closed source Quantum Leaps commercial
10
* licenses.
11
*
12
* The terms of the open source GNU General Public License version 3
13
* can be found at: <www.gnu.org/licenses/gpl-3.0>
14
*
15
* The terms of the closed source Quantum Leaps commercial licenses
16
* can be found at: <www.state-machine.com/licensing>
17
*
18
* Redistributions in source code must retain this top-level comment block.
19
* Plagiarizing this software to sidestep the license obligations is illegal.
20
*
21
* Contact information:
22
* <www.state-machine.com>
23
* <info@state-machine.com>
24
============================================================================*/
32
#ifndef QASSERT_H
33
#define QASSERT_H
34
46
#ifdef Q_NASSERT
/* Q_NASSERT defined--assertion checking disabled */
47
48
/* provide dummy (empty) definitions that don't generate any code... */
49
#define Q_DEFINE_THIS_FILE
50
#define Q_DEFINE_THIS_MODULE(name_)
51
#define Q_ASSERT(test_) ((void)0)
52
#define Q_ASSERT_ID(id_, test_) ((void)0)
53
#define Q_ALLEGE(test_) ((void)(test_))
54
#define Q_ALLEGE_ID(id_, test_) ((void)(test_))
55
#define Q_ERROR() ((void)0)
56
#define Q_ERROR_ID(id_) ((void)0)
57
58
#else
/* Q_NASSERT not defined--assertion checking enabled */
59
60
#ifndef QP_VERSION
/* is quassert.h used outside QP? */
61
62
/* provide typedefs so that qassert.h could be used "standalone"... */
63
70
typedef
int
int_t
;
71
72
#endif
73
87
#define Q_DEFINE_THIS_FILE \
88
static char const Q_this_module_[] = __FILE__;
89
102
#define Q_DEFINE_THIS_MODULE(name_) \
103
static char const Q_this_module_[] = name_;
104
117
#define Q_ASSERT(test_) ((test_) \
118
? (void)0 : Q_onAssert(&Q_this_module_[0], __LINE__))
119
135
#define Q_ASSERT_ID(id_, test_) ((test_) \
136
? (void)0 : Q_onAssert(&Q_this_module_[0], (id_)))
137
150
#define Q_ALLEGE(test_) Q_ASSERT(test_)
151
164
#define Q_ALLEGE_ID(id_, test_) Q_ASSERT_ID((id_), (test_))
165
172
#define Q_ERROR() \
173
Q_onAssert(&Q_this_module_[0], __LINE__)
174
187
#define Q_ERROR_ID(id_) \
188
Q_onAssert(&Q_this_module_[0], (id_))
189
190
#endif
/* Q_NASSERT */
191
192
/*==========================================================================*/
193
#ifdef __cplusplus
194
extern
"C"
{
195
#endif
196
197
#ifndef Q_NORETURN
199
#define Q_NORETURN void
200
#endif
/* Q_NORETURN */
201
229
Q_NORETURN
Q_onAssert
(
char
const
*
const
module,
int_t
const
location);
230
231
#ifdef __cplusplus
232
}
233
#endif
234
242
#define Q_REQUIRE(test_) Q_ASSERT(test_)
243
252
#define Q_REQUIRE_ID(id_, test_) Q_ASSERT_ID((id_), (test_))
253
261
#define Q_ENSURE(test_) Q_ASSERT(test_)
262
271
#define Q_ENSURE_ID(id_, test_) Q_ASSERT_ID((id_), (test_))
272
280
#define Q_INVARIANT(test_) Q_ASSERT(test_)
281
290
#define Q_INVARIANT_ID(id_, test_) Q_ASSERT_ID((id_), (test_))
291
301
#define Q_ASSERT_STATIC(test_) \
302
extern int_t Q_assert_static[(test_) ? 1 : -1]
303
304
#define Q_ASSERT_COMPILE(test_) Q_ASSERT_STATIC(test_)
305
307
#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
308
309
#endif
/* QASSERT_H */
Q_NORETURN
#define Q_NORETURN
Definition:
qassert.h:199
int_t
int int_t
Definition:
qassert.h:70
Q_onAssert
Q_NORETURN Q_onAssert(char const *const module, int_t const location)
Definition:
qutest.c:480
int_t
signed int int_t
Definition:
qep.h:57
include
qassert.h
© 2005-2022 Quantum Leaps
|
Using Online Help
|
QP/C 7.0.1
| Updated on Wed Jun 15 2022
© 2005-2022 Quantum Leaps
|
Using Online Help
|
QP/C 7.0.1
| Updated on Wed Jun 15 2022