BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

Assertion Macro

Macros

#define pj_assert(expr)
 
#define PJ_ASSERT_RETURN(expr, retval)
 
#define PJ_ASSERT_ON_FAIL(expr, exec_on_fail)
 

Detailed Description

Assertion and other helper macros for sanity checking.

Macro Definition Documentation

◆ pj_assert

#define pj_assert (   expr)

Check during debug build that an expression is true. If the expression computes to false during run-time, then the program will stop at the offending statements. For release build, this macro will not do anything.

Parameters
exprThe expression to be evaluated.

◆ PJ_ASSERT_ON_FAIL

#define PJ_ASSERT_ON_FAIL (   expr,
  exec_on_fail 
)

If PJ_ENABLE_EXTRA_CHECK is declared and non-zero, then PJ_ASSERT_ON_FAIL macro will evaluate the expression in expr during run-time. If the expression yields false, assertion will be triggered and exec_on_fail will be executed.

If PJ_ENABLE_EXTRA_CHECK is not declared or is zero, then no run-time checking will be performed. The macro simply evaluates to pj_assert(expr).

◆ PJ_ASSERT_RETURN

#define PJ_ASSERT_RETURN (   expr,
  retval 
)

If PJ_ENABLE_EXTRA_CHECK is declared and the value is non-zero, then PJ_ASSERT_RETURN macro will evaluate the expression in expr during run-time. If the expression yields false, assertion will be triggered and the current function will return with the specified return value.

If PJ_ENABLE_EXTRA_CHECK is not declared or is zero, then no run-time checking will be performed. The macro simply evaluates to pj_assert(expr).

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.