Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * assert_exception.h - exception using assert 00004 * 00005 * Created: Mon Jun 11 19:07:10 2012 00006 * Copyright 2012 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __CORE_ASSERT_EXCEPTION_H_ 00025 #define __CORE_ASSERT_EXCEPTION_H_ 00026 00027 #include <core/exception.h> 00028 00029 #ifdef _ASSERT_H 00030 # undef assert 00031 #else 00032 # if defined __cplusplus && __GNUC__ >= 3 00033 # define __ASSERT_VOID_CAST static_cast<void> 00034 # else 00035 # define __ASSERT_VOID_CAST (void) 00036 # endif 00037 #endif 00038 00039 #define assert(expr) \ 00040 ((expr) \ 00041 ? __ASSERT_VOID_CAST (0) \ 00042 : throw fawkes::Exception("Assertion '%s' failed in %s:%u", \ 00043 __STRING(expr), __FILE__, __LINE__)) 00044 00045 #endif