-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyassert.h
42 lines (37 loc) · 2.89 KB
/
myassert.h
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
#ifndef MYASSERT_H
#define MYASSERT_H
#include <assert.h>
#include "colors.h"
#include "errors_codegen.h"
#define DEBUG_MYASSERT 0
#ifdef DEBUG_MYASSERT
#define MYASSERT(check, error_code, ending) \
do \
{ \
if (!(check)) \
{ \
fprintf(stderr, MAGENTA ">>>>> Error in code! Error code: %s <<<<<\n", #error_code); \
fprintf(stderr, "In File: %s, In Line: %d, In Function: %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__); \
fprintf(stderr, "In this condition:\t\"%s\"\n\n" RESET, #check); \
ending; \
} \
} \
while(0);
#else
#define MYASSERT(check, error_code, ending)
#endif
//===============================================================================================================
//Write Error unclosed
#define USER_ERROR(check, error_code, word, ending) \
do \
{ \
if (!(check)) \
{ \
fprintf(stderr, RED ">>>>> Error! %s <<<<<\n" RESET, ArrayOfErrors[error_code]); \
fprintf(stderr, MAGENTA "%s" RESET, word); \
fprintf(stderr, RED "In File: %s, In Line: %d, In Function: %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__);\
ending; \
} \
} \
while(0);
#endif