diff options
-rw-r--r-- | assert.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/assert.h b/assert.h new file mode 100644 index 0000000..08d84f5 --- /dev/null +++ b/assert.h @@ -0,0 +1,46 @@ +#ifndef __ASSERT_H +#define __ASSERT_H + +/***************************************************************************** + * CONFIG ASSERT THINGS + *****************************************************************************/ + +/* enable to enable asserts */ +#define ASSERT_ON + +/* exit way */ +#define __EXIT_ABBORT + +#ifdef __EXIT_ABBORT + #define __EXIT_WAY exit(1); +#else + #define __EXIT_WAY ; +#endif + + +#ifdef ASSERT_ON +#define __STR(S) #S +#define AS_NULL(X) if ((X)==NULL)\ +{\ + printf("\033[1;34m%s:%d GOTCHA NULL\033[0m\n",__FILE__,__LINE__);\ + __EXIT_WAY;\ +} + +#define AS_RANGE(X,A,B) + +#define AS_EXPR(X) if ((X))\ +{\ + printf("\033[1;34m%s:%d assert:%s\033[0m\n",__FILE__,__LINE__,__STR(X));\ + __EXIT_WAY;\ +} + +#else + +#define AS_NULL(X) +#define AS_RANGE(X,A,B) +#define AS_EXPR(X) + +#endif + +#endif + |