|
QP/C++
|
00001 /***************************************************************************** 00002 * Product: QP/C/C++ 00003 * Last Updated for Version: 4.5.03 00004 * Date of the Last Update: Jan 16, 2013 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved. 00011 * 00012 * This program is open source software: you can redistribute it and/or 00013 * modify it under the terms of the GNU General Public License as published 00014 * by the Free Software Foundation, either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * Alternatively, this program may be distributed and modified under the 00018 * terms of Quantum Leaps commercial licenses, which expressly supersede 00019 * the GNU General Public License and are specifically designed for 00020 * licensees interested in retaining the proprietary status of their code. 00021 * 00022 * This program is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 * GNU General Public License for more details. 00026 * 00027 * You should have received a copy of the GNU General Public License 00028 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 * 00030 * Contact information: 00031 * Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 * http://www.state-machine.com 00033 * e-mail: info@quantum-leaps.com 00034 *****************************************************************************/ 00035 #ifndef qassert_h 00036 #define qassert_h 00037 00055 #ifdef Q_NASSERT /* Q_NASSERT defined--assertion checking disabled */ 00056 00057 #define Q_DEFINE_THIS_FILE 00058 #define Q_DEFINE_THIS_MODULE(name_) 00059 #define Q_ASSERT(test_) ((void)0) 00060 #define Q_ASSERT_ID(id_, test_) ((void)0) 00061 #define Q_ALLEGE(test_) ((void)(test_)) 00062 #define Q_ALLEGE_ID(id_, test_) ((void)(test_)) 00063 #define Q_ERROR() ((void)0) 00064 #define Q_ERROR_ID(id_) ((void)0) 00065 00066 #else /* Q_NASSERT not defined--assertion checking enabled */ 00067 00072 #define Q_DEFINE_THIS_FILE \ 00073 static char_t const Q_ROM Q_ROM_VAR l_this_file[] = __FILE__; 00074 00079 #define Q_DEFINE_THIS_MODULE(name_) \ 00080 static char_t const Q_ROM Q_ROM_VAR l_this_file[] = name_; 00081 00089 #define Q_ASSERT(test_) \ 00090 ((test_) ? (void)0 : Q_onAssert(&l_this_file[0], (int_t)__LINE__)) 00091 00102 #define Q_ASSERT_ID(id_, test_) \ 00103 ((test_) ? (void)0 : Q_onAssert(&l_this_file[0], (int_t)(id_)) 00104 00114 #define Q_ALLEGE(test_) Q_ASSERT(test_) 00115 00127 #define Q_ALLEGE_ID(id_, test_) Q_ASSERT_ID(id_, test_) 00128 00134 #define Q_ERROR() \ 00135 Q_onAssert(&l_this_file[0], (int_t)__LINE__) 00136 00144 #define Q_ERROR_ID(id_) \ 00145 Q_onAssert(l_this_file, (int_t)(id_)) 00146 00147 #endif /* Q_NASSERT */ 00148 00149 #ifdef __cplusplus 00150 extern "C" { 00151 #endif 00152 00158 typedef int int_t; 00159 00167 void Q_onAssert(char_t const Q_ROM * const Q_ROM_VAR file, int_t line); 00168 00169 #ifdef __cplusplus 00170 } 00171 #endif 00172 00178 #define Q_REQUIRE(test_) Q_ASSERT(test_) 00179 00185 #define Q_REQUIRE_ID(id_, test_) Q_ASSERT_ID(id_, test_) 00186 00192 #define Q_ENSURE(test_) Q_ASSERT(test_) 00193 00199 #define Q_ENSURE_ID(id_, test_) Q_ASSERT_ID(id_, test_) 00200 00206 #define Q_INVARIANT(test_) Q_ASSERT(test_) 00207 00213 #define Q_INVARIANT_ID(id_, test_) Q_ASSERT_ID(id_, test_) 00214 00220 #define Q_ASSERT_COMPILE(test_) \ 00221 extern int_t Q_assert_compile[(test_) ? 1 : -1] 00222 00223 #endif /* qassert_h */
1.7.6.1