00001 /* 00002 The lestes compiler suite 00003 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy 00004 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika 00005 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala 00006 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina 00007 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda 00008 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar 00009 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; version 2 of the License. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 See the full text of the GNU General Public License version 2, and 00021 the limitations in the file doc/LICENSE. 00022 00023 By accepting the license the licensee waives any and all claims 00024 against the copyright holder(s) related in whole or in part to the 00025 work, its use, and/or the inability to use it. 00026 00027 */ 00028 #ifndef lestes__std___lassert_hh___included 00029 #define lestes__std___lassert_hh___included 00030 00031 /*! \file 00032 Assertion checking macros. 00033 \author Rudo, the new lassert2 macro 00034 \author Rudo, added lassert_event 00035 \author Rudo, the new lassert3 and lassert2l macros 00036 \author JAZ, include file messages.hh with standard assertation messages. 00037 */ 00038 00039 #include <lestes/package.hh> 00040 #include <lestes/std/data_types.hh> 00041 #include <lestes/std/event_macros.hh> 00042 #include <lestes/std/messages.hh> 00043 00044 #include <lestes/std/source_location.hh> 00045 00046 /* __func__ absence workaround */ 00047 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ 00048 || (defined(__GNUC__) && (__GNUC__*1000+__GNUC_MINOR__) >= 3000) 00049 00050 #define LESTES__func__ __func__ 00051 #else 00052 #if (defined(_MSC_VER) && _MSC_VER < 1300) 00053 #define LESTES__func__ "unknown funtion or unsupported compiler" 00054 #else 00055 #define LESTES__func__ __FUNCTION__ /* hope for the best */ 00056 #endif 00057 #endif 00058 00059 00060 /*! 00061 * \brief When given expression evaluates to false, the program is aborted. 00062 * 00063 * Should be used instead of the standard assert macro. 00064 * 00065 * \param e The expression to evaluate, it is evaluated only once. 00066 * \param msg If not empty, it is printed after the "assertion failed" info. 00067 * \param loc source_location; if not NULL, it is printed before the "assertion failed" info. 00068 */ 00069 #define lassert3( e, msg, loc ) \ 00070 ((e) ? (void)0 : ::lestes::std::lassert_fail( #e, __FILE__, __LINE__, LESTES__func__, (msg), (loc) )) 00071 00072 //! a shortcut to lestes3 without a location 00073 #define lassert2( e, msg ) lassert3( e, (msg), NULL ) 00074 00075 //! a shortcut to lassert3 without a message 00076 #define lassert2loc( e, loc ) lassert3( e, "", (loc) ) 00077 00078 //! a shortcut to lassert2 without a message 00079 #define lassert( e ) lassert2( e, "" ) 00080 00081 package(lestes); 00082 package(std); 00083 00084 //! lassert_event is trigerred when a lassertion fails (including ignored lassertions) 00085 declare_event( lassert_event ); 00086 00087 //! Called when an assertion fails. 00088 void lassert_fail( lstring assertion, 00089 lstring filename, ulint line, lstring function, 00090 lstring message, ptr<source_location> ) 00091 #ifdef __GNUC__ 00092 #ifndef CONTINUABLE_ASSERTIONS 00093 __attribute__ ((noreturn)) 00094 #endif 00095 #endif 00096 ; 00097 00098 end_package(std); 00099 end_package(lestes); 00100 00101 #endif // lestes__std___lassert_hh___included 00102 /* vim: set ft=lestes : */
1.5.1-20070107