PebbleOS
Loading...
Searching...
No Matches
Assertions

Checks that raise a fatal error when an expression is false. More...

Macros

#define PBL_ASSERT(expr, fmt, ...)
 Panic with a message if an expression is false.
 
#define PBL_ASSERTN(expr)
 Panic if an expression is false.
 

Detailed Description

Checks that raise a fatal error when an expression is false.

Always enabled. PBL_ASSERTN() carries no message and is the cheaper of the two.

PBL_ASSERTN(buf != nullptr);
PBL_ASSERT(len <= sizeof(s_buf), "len %zu", len);
#define PBL_ASSERT(expr, fmt,...)
Panic with a message if an expression is false.
Definition assert.h:30
#define PBL_ASSERTN(expr)
Panic if an expression is false.
Definition assert.h:42

Macro Definition Documentation

◆ PBL_ASSERT

#define PBL_ASSERT (   expr,
  fmt,
  ... 
)
Value:
do { \
if (PBL_UNLIKELY(!(expr))) { \
PBL_PANIC_MSG("*** ASSERTION FAILED: " fmt, ##__VA_ARGS__); \
} \
} while (0)
#define PBL_UNLIKELY(x)
Branch prediction hint for a condition that is unlikely to hold.
Definition compiler.h:140

Panic with a message if an expression is false.

Parameters
exprExpression.
fmtprintf-style message; must be a string literal.
...Message arguments.

◆ PBL_ASSERTN

#define PBL_ASSERTN (   expr)
Value:
do { \
if (PBL_UNLIKELY(!(expr))) { \
PBL_PANIC_BARE(); \
} \
} while (0)

Panic if an expression is false.

Parameters
exprExpression.