-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassert.h
25 lines (20 loc) · 1.14 KB
/
assert.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
#ifndef __ASSERT_H__
#define __ASSERT_H__
#include <stdio.h>
void __print_backtrace__(void);
#define assert(x) \
do \
{ \
if (!(x)) \
{ \
printf("\nAssertion failed at %s:%d `%s`\n", __FILE__, __LINE__, #x); \
__print_backtrace__(); \
} \
} while (0)
#define failwith(x) \
do \
{ \
printf("Code failed at %s:%d `%s`\n", __FILE__, __LINE__, x); \
__print_backtrace__(); \
} while (1)
#endif