qassert.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Product:  QP/C/C++
00003 * Last Updated for Version: 4.0.00
00004 * Date of the Last Update:  Apr 05, 2008
00005 *
00006 *                    Q u a n t u m     L e a P s
00007 *                    ---------------------------
00008 *                    innovating embedded systems
00009 *
00010 * Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved.
00011 *
00012 * This software may be distributed and modified under the terms of the GNU
00013 * General Public License version 2 (GPL) as published by the Free Software
00014 * Foundation and appearing in the file GPL.TXT included in the packaging of
00015 * this file. Please note that GPL Section 2[b] requires that all works based
00016 * on this software must also be made publicly available under the terms of
00017 * the GPL ("Copyleft").
00018 *
00019 * Alternatively, this software may be distributed and modified under the
00020 * terms of Quantum Leaps commercial licenses, which expressly supersede
00021 * the GPL and are specifically designed for licensees interested in
00022 * retaining the proprietary status of their code.
00023 *
00024 * Contact information:
00025 * Quantum Leaps Web site:  http://www.quantum-leaps.com
00026 * e-mail:                  info@quantum-leaps.com
00027 *****************************************************************************/
00028 #ifndef qassert_h
00029 #define qassert_h
00030 
00047 #ifdef Q_NASSERT          /* Q_NASSERT defined--assertion checking disabled */
00048 
00049     #define Q_DEFINE_THIS_FILE
00050     #define Q_DEFINE_THIS_MODULE(name_)
00051     #define Q_ASSERT(test_)    ((void)0)
00052     #define Q_ALLEGE(test_)    ((void)(test_))
00053     #define Q_ERROR()          ((void)0)
00054 
00055 #else                  /* Q_NASSERT not defined--assertion checking enabled */
00056 
00057     #ifdef __cplusplus
00058         extern "C" {
00059     #endif
00060 
00068     /*lint -sem(Q_onAssert, r_no)                Q_onAssert() never returns */
00069     void Q_onAssert(char const Q_ROM * const Q_ROM_VAR file, int line);
00070 
00071     #ifdef __cplusplus
00072         }
00073     #endif
00074 
00079     #define Q_DEFINE_THIS_FILE \
00080         static char const Q_ROM Q_ROM_VAR l_this_file[] = __FILE__;
00081 
00086     #define Q_DEFINE_THIS_MODULE(name_) \
00087         static char const Q_ROM Q_ROM_VAR l_this_file[] = #name_;
00088 
00095     #define Q_ASSERT(test_) \
00096         if (test_) { \
00097         } \
00098         else (Q_onAssert(l_this_file, __LINE__))
00099 
00108     #define Q_ALLEGE(test_)    Q_ASSERT(test_)
00109 
00114     #define Q_ERROR() \
00115         (Q_onAssert(l_this_file, __LINE__))
00116 
00117 #endif                                                         /* Q_NASSERT */
00118 
00123 #define Q_REQUIRE(test_)   Q_ASSERT(test_)
00124 
00129 #define Q_ENSURE(test_)    Q_ASSERT(test_)
00130 
00135 #define Q_INVARIANT(test_) Q_ASSERT(test_)
00136 
00142 #define Q_ASSERT_COMPILE(test_) \
00143     extern char Q_assert_compile[(test_)]
00144 
00145 #endif                                                         /* qassert_h */

Generated on Sat Nov 15 13:53:46 2008 for QP/C++ by  doxygen 1.5.4