S2OPC OPCUA Toolkit
Macros | Typedefs | Functions
sopc_assert.h File Reference

Redirection of code assertions depending on user needs. Assert provides one of the following indirection for the assertion "SOPC_ASSERT" macro, depending on build flags: More...

#include <assert.h>

Go to the source code of this file.

Macros

#define SOPC_PP_XSTR(x)   #x
 
#define SOPC_PP_STR(x)   SOPC_PP_XSTR(x)
 
#define WITH_MINIMAL_FOOTPRINT   0
 
#define SOPC_ASSERT_CONTEXT(context)   __FILE__ ":" SOPC_PP_STR(__LINE__) " => " #context
 
#define SOPC_ASSERT   assert
 

Typedefs

typedef void SOPC_Assert_UserCallback(const char *context)
 User-defined implementation of Fail-Safe behavior. This method shall be provided when WITH_USER_ASSERT is defined. This method shall not use any code implementation that relies on SOPC_ASSERT. More...
 

Functions

void SOPC_Assert_Set_UserCallback (SOPC_Assert_UserCallback *callback)
 Define the user event to call in case of Assert failure. More...
 
void SOPC_Assert_Failure (const char *context)
 Called by SOPC_ASSERT in case of failure. More...
 

Detailed Description

Redirection of code assertions depending on user needs. Assert provides one of the following indirection for the assertion "SOPC_ASSERT" macro, depending on build flags:

Macro Definition Documentation

◆ SOPC_PP_XSTR

#define SOPC_PP_XSTR (   x)    #x

These macros are required to convert at build_time the LINE into a string

◆ SOPC_PP_STR

#define SOPC_PP_STR (   x)    SOPC_PP_XSTR(x)

◆ WITH_MINIMAL_FOOTPRINT

#define WITH_MINIMAL_FOOTPRINT   0

◆ SOPC_ASSERT_CONTEXT

#define SOPC_ASSERT_CONTEXT (   context)    __FILE__ ":" SOPC_PP_STR(__LINE__) " => " #context

SOPC_ASSERT_CONTEXT expands the calling context, only if WITH_MINIMAL_FOOTPRINT option is not set

◆ SOPC_ASSERT

#define SOPC_ASSERT   assert

SOPC_ASSERT implementation depends on build options (see module description)

Typedef Documentation

◆ SOPC_Assert_UserCallback

typedef void SOPC_Assert_UserCallback(const char *context)

User-defined implementation of Fail-Safe behavior. This method shall be provided when WITH_USER_ASSERT is defined. This method shall not use any code implementation that relies on SOPC_ASSERT.

Parameters
contextThe context of failed assertion. Note that when WITH_MINIMAL_FOOTPRINT option is set, this parameter will always be empty.
Postcondition
This function has no constraint return (may return or not).

Function Documentation

◆ SOPC_Assert_Set_UserCallback()

void SOPC_Assert_Set_UserCallback ( SOPC_Assert_UserCallback callback)

Define the user event to call in case of Assert failure.

Parameters
callbackCallback event.

◆ SOPC_Assert_Failure()

void SOPC_Assert_Failure ( const char *  context)

Called by SOPC_ASSERT in case of failure.

Parameters
contextThe context of failed assertion.
Postcondition
This function does not return