Skip to content

Commit

Permalink
Merge pull request #324 from lf-lang/fix-lf-assert
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj authored Dec 28, 2023
2 parents 1c12a9e + 6b35131 commit fa07f2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,3 @@ define(LF_PACKAGE_DIRECTORY)
define(LF_FILE_SEPARATOR)
define(WORKERS_NEEDED_FOR_FEDERATE)
define(LF_ENCLAVES)
define(LF_NOASSERT)
9 changes: 4 additions & 5 deletions include/core/utils/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,16 @@ void lf_register_print_function(print_message_function_t* function, int log_leve
/**
* Assertion handling. LF_ASSERT can be used as a short hand for verifying
* a condition and calling `lf_print_error_and_exit` if it is not true.
* By definng `LF_NOASSERT` this check is not performed.
* This is optimized away if the NDEBUG flag is defined.
*/
#if defined(LF_NOASSERT)
#define LF_ASSERT(condition, format, ...) \
while(0) { }
#if defined(NDEBUG)
#define LF_ASSERT(condition, format, ...) (condition)
#else
#define LF_ASSERT(condition, format, ...) \
do { \
if (!(condition)) { \
lf_print_error_and_exit(format, ##__VA_ARGS__); \
} \
} while(0)
#endif // LF_NOASSERT
#endif // NDEBUG
#endif /* UTIL_H */

0 comments on commit fa07f2f

Please sign in to comment.