[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 <stdio.h>
|
||||
|
||||
#define ASSERT(_cond, ...) do { \
|
||||
if (!(_cond)) { \
|
||||
fprintf(stderr, "ASSERT FAILED:\n" __VA_ARGS__); \
|
||||
exit(1); \
|
||||
} \
|
||||
#define ASSERT(_cond, ...) do { \
|
||||
if (!(_cond)) { \
|
||||
fprintf(stderr, "%s:%d: assertion failed:\n", \
|
||||
__FILE__, __LINE__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_NON_NULL(_ptr, _who) \
|
||||
|
|
Loading…
Reference in New Issue