00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _assert_pp_h
00020 #define _assert_pp_h
00021
00022 #include <stdlib.h>
00023
00024 #if !defined(DEBUG)
00025 #define NO_PRECONDITIONS
00026 #define NO_POSTCONDITIONS
00027 #endif
00028
00029 #if !defined(NO_POSTCONDITIONS) || !defined(NO_PRECONDITIONS)
00030 #if defined(__GNUC__)
00031 #define ASSERT_FUNCATTR_NORETURN __attribute__((__noreturn__))
00032 #else
00033 #define ASSERT_FUNCATTR_NORETURN
00034 #endif
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 extern int pp_failed(char *file, unsigned int line,
00050 const char* func, char *type, char *expr)
00051 ASSERT_FUNCATTR_NORETURN;
00052 #ifdef __cplusplus
00053 }
00054 #endif
00055 #endif
00056
00057 #ifndef NO_PRECONDITIONS
00058 #define pp_decl(decl) decl
00059 #define pp_block(block) block
00060
00061
00062
00063
00064
00065
00066
00067
00068 #define require(precon) \
00069 ((void)((precon) ? 0 : \
00070 (pp_failed(__FILE__,__LINE__,__PRETTY_FUNCTION__,"precondition",__STRING(precon)))))
00071 #else
00072 #define require(x)
00073 #define pp_decl(x)
00074 #define pp_block(x)
00075 #endif
00076
00077 #ifndef NO_POSTCONDITIONS
00078
00079
00080
00081
00082
00083
00084
00085
00086 #define ensure(postcon) \
00087 ((void)((postcon) ? 0 : \
00088 (pp_failed(__FILE__,__LINE__,__PRETTY_FUNCTION__,"postcondition",__STRING(postcon)))))
00089 #else
00090 #define ensure(x)
00091 #endif
00092
00093 #endif