nRF5 SDK for Thread and Zigbee v3.2.0
Macros
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)   typedef zb_int_t ZB_ASSERT_CAT(assert, __LINE__)[(expr) ? 1 : -1]
 
#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

#define ZB_ASSERT_COMPILE_DECL (   expr)    typedef zb_int_t ZB_ASSERT_CAT(assert, __LINE__)[(expr) ? 1 : -1]

Check condition at compile time in the declaration block

Parameters
expr- expression to check.
#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.
#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.
#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
#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
#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

Documentation feedback | Developer Zone | Subscribe | Updated