assert.h

Go to the documentation of this file.
00001 00004 /* 00005 * Copyright © 2001 Sofus Mortensen 00006 * 00007 * This material is provided "as is", with absolutely no warranty 00008 * expressed or implied. Any use is at your own risk. Permission to 00009 * use or copy this software for any purpose is hereby granted without 00010 * fee, provided the above notices are retained on all copies. 00011 * Permission to modify the code and to distribute modified code is 00012 * granted, provided the above notices are retained, and a notice that 00013 * the code was modified is included with the above copyright notice. 00014 * 00015 * This header is part of comet. 00016 * http://www.lambdasoft.dk/comet 00017 */ 00018 00019 #ifndef COMET_ASSERT_H 00020 #define COMET_ASSERT_H 00021 00022 # if defined(COMET_ASSERT_THROWS) || defined(COMET_ASSERT_THROWS_ALWAYS) 00023 # if defined(COMET_ASSERT_THROWS_ALWAYS) || !defined(NDEBUG) 00024 namespace comet 00025 { 00029 00030 00033 struct assert_failed : std::runtime_error 00034 { 00035 assert_failed( const char *val) : runtime_error(val) {} 00036 }; 00038 } 00039 # define COMET_ASSERT(x_) if (x_) ; else throw comet::assert_failed("Assert Failed: " #x_ ); 00040 # define COMET_THROWS_ASSERT throw( comet::assert_failed) 00041 # else 00042 # define COMET_ASSERT(x_) ; 00043 # endif 00044 00045 # else 00046 # define COMET_THROWS_ASSERT throw() 00047 # ifndef __CYGWIN__ 00048 00049 # include <crtdbg.h> 00050 # define COMET_ASSERT _ASSERTE 00051 00052 # else 00053 00054 # include <assert.h> 00055 # define COMET_ASSERT assert 00056 # endif 00057 # endif 00058 00065 00066 #endif