Developing with ZBOSS for Zigbee
Static (compile-time) asserts

Macros

#define ZB_ASSERT_COMPILE_TIME(expr)   ((void)(zb_int_t (*)[(expr) ? 1 : -1])0)
 
#define ZB_ASSERT_COMPILE_TIME_EXPR(expr)   ((zb_int_t)((zb_int_t (*)[(expr) ? 1 : -1])0))
 
#define ZB_ASSERT_COMPILE_DECL(expr)
 
#define ZB_ASSERT_TYPE_SIZE_NOT_GREATER(type, limit)   ZB_ASSERT_COMPILE_DECL(sizeof(type) <= (limit))
 
#define ZB_ASSERT_TYPE_SIZE_NOT_LESS(type, limit)   ZB_ASSERT_COMPILE_DECL(sizeof(type) >= (limit))
 
#define ZB_ASSERT_TYPE_SIZE_EQ(type, limit)   ZB_ASSERT_COMPILE_DECL(sizeof(type) == (limit))
 

Detailed Description

Macro Definition Documentation

◆ ZB_ASSERT_COMPILE_DECL

#define ZB_ASSERT_COMPILE_DECL (   expr)

Check condition at compile time in the declaration block

Parameters
expr- expression to check.

◆ ZB_ASSERT_COMPILE_TIME

#define ZB_ASSERT_COMPILE_TIME (   expr)    ((void)(zb_int_t (*)[(expr) ? 1 : -1])0)

Check condition at compile time in the code (not declaration block)

Parameters
expr- expression to check.

◆ ZB_ASSERT_COMPILE_TIME_EXPR

#define ZB_ASSERT_COMPILE_TIME_EXPR (   expr)    ((zb_int_t)((zb_int_t (*)[(expr) ? 1 : -1])0))

Check condition at compile time in the code (not declaration block), return 0 To be used inside an expressions.

Parameters
expr- expression to check.

◆ ZB_ASSERT_TYPE_SIZE_EQ

#define ZB_ASSERT_TYPE_SIZE_EQ (   type,
  limit 
)    ZB_ASSERT_COMPILE_DECL(sizeof(type) == (limit))

Ensures, that size of type ‘type’ is equal to the ‘limit’. If it is not, compilation is aborted.

Parameters
type- type name
limit- size limit

◆ ZB_ASSERT_TYPE_SIZE_NOT_GREATER

#define ZB_ASSERT_TYPE_SIZE_NOT_GREATER (   type,
  limit 
)    ZB_ASSERT_COMPILE_DECL(sizeof(type) <= (limit))

Ensures, that size of type ‘type’ is not greater than ‘limit’. If it is not, compilation is aborted.

Parameters
type- type name
limit- size limit

◆ ZB_ASSERT_TYPE_SIZE_NOT_LESS

#define ZB_ASSERT_TYPE_SIZE_NOT_LESS (   type,
  limit 
)    ZB_ASSERT_COMPILE_DECL(sizeof(type) >= (limit))

Ensures, that size of type ‘type’ is not less than ‘limit’. If it is not, compilation is aborted.

Parameters
type- type name
limit- size limit