Logo
DSR GreenBOSS  1.1.0
Macros | Functions

Macros

#define ZB_INLINE_ASSERT(expr)   ZB_INLINE_ASSERT_SIMPLE((expr)),
 Assert which can be used inside an expression. More...
 
#define ZB_ASSERT_COMPILE_TIME(expr)   ((void)(zb_int_t (*)[(expr) ? 1 : -1])0)
 Checks condition at compile time in the code (not declaration block). More...
 
#define ZB_ASSERT_COMPILE_TIME_EXPR(expr)   ((zb_int_t)((zb_int_t (*)[(expr) ? 1 : -1])0))
 Checks condition at compile time in the code (not declaration block), returns 0. More...
 
#define ZB_ASSERT_COMPILE_DECL(expr)   typedef zb_int_t ZB_ASSERT_CAT(assert, __LINE__)[(expr) ? 1 : -1]
 Checks condition at compile time in the declaration block. More...
 
#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'. More...
 
#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'. More...
 
#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'. More...
 

Functions

void zb_abort (char *caller_file, int caller_line)
 Traces current location, aborts current program execution - with core dump if possible. More...
 
void zb_assert (zb_char_t *file_name, zb_int_t line_number)
 Asserts printing diagnostic and forcing a core dump. More...
 

Detailed Description

Macro Definition Documentation

§ ZB_INLINE_ASSERT

#define ZB_INLINE_ASSERT (   expr)    ZB_INLINE_ASSERT_SIMPLE((expr)),

Assert which can be used inside an expression.

Parameters
exprExpression to check
Returns
Always 1 (true)

§ ZB_ASSERT_COMPILE_TIME

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

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

Parameters
exprExpression to check

§ ZB_ASSERT_COMPILE_TIME_EXPR

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

Checks condition at compile time in the code (not declaration block), returns 0.

To be used inside expressions.

Parameters
exprExpression to check

§ ZB_ASSERT_COMPILE_DECL

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

Checks condition at compile time in the declaration block.

Parameters
exprExpression to check

§ 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
typeType name
limitSize 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
typeType name
limitSize limit

§ 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
typeType name
limitSize limit

Function Documentation

§ zb_abort()

void zb_abort ( char *  caller_file,
int  caller_line 
)

Traces current location, aborts current program execution - with core dump if possible.

Parameters
caller_fileSource file name
caller_lineLine in the source

References TRACE_ERROR, and TRACE_MSG.

§ zb_assert()

void zb_assert ( zb_char_t file_name,
zb_int_t  line_number 
)

Asserts printing diagnostic and forcing a core dump.

Parameters
file_nameSource file name
line_numberLine in the source

References TRACE_ERROR, and TRACE_MSG.