00001 #ifndef CCTOOLS_ASSERT_H
00002 #define CCTOOLS_ASSERT_H
00003
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006
00007
00008 #ifndef CCTOOLS_SOURCE
00009 # define CCTOOLS_SOURCE "test"
00010 #endif
00011
00012 #ifndef NDEBUG
00013 # define cctools_assert(exp) \
00014 do {\
00015 if (!(exp)) {\
00016 fprintf(stderr, "%s: %s:%d[%s]: Assertion '%s' failed.\n", __func__, __FILE__, __LINE__, CCTOOLS_SOURCE, #exp);\
00017 fflush(stderr);\
00018 abort();\
00019 }\
00020 } while (0)
00021 #else
00022 # define cctools_assert(exp) ((void)0)
00023 #endif
00024
00025 #undef assert
00026 #define assert(expr) cctools_assert(expr)
00027
00028 #endif