Skip to content

Commit

Permalink
Merge pull request #376 from lf-lang/better-assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj authored Mar 1, 2024
2 parents dbba138 + 6d2e05d commit 639bbdd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions logging/api/logging_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,22 @@
#define LF_ASSERT(condition, format, ...) \
do { \
if (!(condition)) { \
lf_print_error_and_exit(format, ##__VA_ARGS__); \
lf_print_error_and_exit("`"format "`. Failed assertion in %s:%d(%s):(" #condition \
") != true`", ##__VA_ARGS__, __FILE__, __LINE__, __func__); \
} \
} while(0)
#define LF_ASSERTN(condition, format, ...) \
do { \
if (condition) { \
lf_print_error_and_exit(format, ##__VA_ARGS__); \
lf_print_error_and_exit("`"format "`. Failed assertion in %s:%d(%s):(" #condition \
") != false`", ##__VA_ARGS__, __FILE__, __LINE__, __func__); \
} \
} while(0)
#define LF_ASSERT_NON_NULL(pointer) \
do { \
if (!(pointer)) { \
lf_print_error_and_exit("Assertion failed: pointer is NULL Out of memory?."); \
lf_print_error_and_exit("`Out of memory?` Assertion failed in %s:%d(%s):`" #pointer " == NULL`",\
__FILE__, __LINE__, __func__); \
} \
} while(0)
#endif // NDEBUG

0 comments on commit 639bbdd

Please sign in to comment.