summaryrefslogtreecommitdiff
path: root/assert.h
blob: 08d84f527a7b695af5ef96476fc05cc53118818e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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