AutosarOS
assert.h File Reference

Assert macros and functions. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for assert.h:

Go to the source code of this file.

Macros

#define assert(expression)
 
#define assertMsg(expression, message)
 
#define ASSERT_BUFFER_SIZE   size
 
#define STATIC_ASSERT_BUFFER
 If defined the error buffer will be declared as static. More...
 
#define BREAK_ON_ASSERT
 If this is defined a break opcode will be executed before abort() is called. More...
 

Detailed Description

Assert macros and functions.

Date
2019-09-02
Author
Pascal Romahn

Definition in file assert.h.

Macro Definition Documentation

◆ assert

#define assert (   expression)
Parameters
expressionExpression to test for

The assert() macro tests the given expression and if it is false, the calling process is terminated. A diagnostic message is written to the error buffer and the function abort() is called, effectively terminating the program.

If expression is true, the assert() macro does nothing.

The assert() macro may be removed at compile time by defining NDEBUG as a macro (e.g., by using the compiler option -DNDEBUG).

Definition at line 37 of file assert.h.

◆ ASSERT_BUFFER_SIZE

#define ASSERT_BUFFER_SIZE   size
Parameters
sizeSize of buffer in bytes

A buffer of the specified size will be created to write the error message into. If the message is longer than the buffer no message will be created.

If not defined no buffer will be created.

Definition at line 65 of file assert.h.

◆ assertMsg

#define assertMsg (   expression,
  message 
)
Parameters
expressionExpression to test for
messageMessage to write instead of expression

The assert() macro tests the given expression and if it is false, the calling process is terminated. The passed message is written to the error buffer and the function abort() is called, effectively terminating the program.

If expression is true, the assert() macro does nothing.

The assertMsg() macro may be removed at compile time by defining NDEBUG as a macro (e.g., by using the compiler option -DNDEBUG).

Definition at line 54 of file assert.h.

◆ BREAK_ON_ASSERT

#define BREAK_ON_ASSERT

If this is defined a break opcode will be executed before abort() is called.

This way the debugger will break without explicitly setting a breakpoint.

Definition at line 81 of file assert.h.

◆ STATIC_ASSERT_BUFFER

#define STATIC_ASSERT_BUFFER

If defined the error buffer will be declared as static.

Definition at line 72 of file assert.h.