Libecoli 0.4.0
Extensible COmmand LIne library
 
Loading...
Searching...
No Matches
Assert

Assertion helpers. More...

Macros

#define ec_assert_print(expr, args...)
 
#define EC_CHECK_ARG(cond, ret, err)
 

Detailed Description

Assertion helpers.

Helpers to check at runtime if a condition is true, or otherwise either abort (exit program) or return an error.

Macro Definition Documentation

◆ ec_assert_print

#define ec_assert_print ( expr,
args... )
Value:
__ec_assert_print(expr, #expr, args)

Abort if the condition is false.

If expression is false this macro will prints an error message to standard error and terminates the program by calling abort(3).

Parameters
exprThe expression to be checked.
argsThe format string, optionally followed by other arguments.

Definition at line 35 of file ecoli_assert.h.

◆ EC_CHECK_ARG

#define EC_CHECK_ARG ( cond,
ret,
err )
Value:
do { \
if (!(cond)) { \
errno = err; \
return ret; \
} \
} while(0)

Check a condition or return.

If the condition is true, do nothing. If it is false, set errno and return the specified value.

Parameters
condThe condition to test.
retThe value to return.
errThe errno to set.

Definition at line 61 of file ecoli_assert.h.