Assertions and checks can be done by using the following macros:
Debug, logging and assertion macros.
#define HERMES_ASSERT(expr)
Errors if expression is false.
Definition: debug.h:125
#define HERMES_ASSERT_WITH_LOG(expr, M)
Errors if expression is false with message.
Definition: debug.h:134
#define HERMES_CHECK_EXP_WITH_LOG(expr, M)
Warns if expression is false with message.
Definition: debug.h:104
#define HERMES_CHECK_EXP(expr)
Warns if expression is false.
Definition: debug.h:95
Sometimes you want some piece of code to be compiled only in debug mode, this macro can be convenient in this situation:
HERMES_DEBUG_CODE(CODE_CONTENT)
Then use this way:
int main() {
HERMES_DEBUG_CODE(
int a = 3;
printf("%d", a);
)
return 0;
}
both lines will not be included in release.