[util] better ASSERT macro
This commit is contained in:
parent
8f6ab23830
commit
dfa3c39cec
13
src/util.h
13
src/util.h
|
@ -2,11 +2,14 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define ASSERT(_cond, ...) do { \
|
#define ASSERT(_cond, ...) do { \
|
||||||
if (!(_cond)) { \
|
if (!(_cond)) { \
|
||||||
fprintf(stderr, "ASSERT FAILED:\n" __VA_ARGS__); \
|
fprintf(stderr, "%s:%d: assertion failed:\n", \
|
||||||
exit(1); \
|
__FILE__, __LINE__); \
|
||||||
} \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
|
fprintf(stderr, "\n"); \
|
||||||
|
exit(1); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ASSERT_NON_NULL(_ptr, _who) \
|
#define ASSERT_NON_NULL(_ptr, _who) \
|
||||||
|
|
Loading…
Reference in New Issue