[util] better ASSERT macro

This commit is contained in:
Milo Turner 2020-02-08 08:46:05 -05:00
parent 8f6ab23830
commit dfa3c39cec
1 changed files with 8 additions and 5 deletions

View File

@ -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) \