-
Notifications
You must be signed in to change notification settings - Fork 0
/
ahAssert.C
66 lines (55 loc) · 1.6 KB
/
ahAssert.C
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# include <stdlib.h>
# include <stdio.h>
# include <stdarg.h>
# include <ahAssert.H>
# include <ahDefs.H>
/*
These debug functions are only defined in basic.H if DEBUG flag is
defined. However, since basic.o is destined to be a library and that
is not frequently compiled, we do not use the preprocessor for
conditioning the functions definitions. Because they are in library,
they are only used if they are inquired. So, we minimize misuse
e.g. if we forget to define DEBUG, we get a "undefined reference"
message while linking symbol using DEBUG
*/
void _assert(const char *exp, const char* fileName, unsigned lineNumber)
{
MESSAGE("Iion %s in line %u file %s violated\n",
exp, lineNumber, fileName);
abort();
}
void _assert(const char *exp,
const char* fileName,
unsigned int lineNumber,
const char* format,
...)
{
MESSAGE("Iion %s in line %u file %s violated\n",
exp, lineNumber, fileName);
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
abort();
}
void _Warning(const char *exp, const char* fileName, unsigned lineNumber)
{
MESSAGE("Condition %s in line %u file %s has been violated\n"
"Programmer decided does not abort on that violation\n",
exp, lineNumber, fileName);
}
void _Warning(const char *exp,
const char* fileName,
unsigned int lineNumber,
const char* format,
...)
{
MESSAGE("Warning %s in line %u file %s\n"
"(Programmer decided does not abort on that violation)\n",
exp, lineNumber, fileName);
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
abort();
}