S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_assert.h
Go to the documentation of this file.
1/*
2 * Licensed to Systerel under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work
4 * for additional information regarding copyright ownership.
5 * Systerel licenses this file to you under the Apache
6 * License, Version 2.0 (the "License"); you may not use this
7 * file except in compliance with the License. You may obtain
8 * a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
37#ifndef SOPC_ASSERT_H_
38#define SOPC_ASSERT_H_
39
43#define SOPC_PP_XSTR(x) #x
44#define SOPC_PP_STR(x) SOPC_PP_XSTR(x)
45
46#ifndef WITH_MINIMAL_FOOTPRINT
47#define WITH_MINIMAL_FOOTPRINT 0
48#endif
49
53#if WITH_MINIMAL_FOOTPRINT
54#define SOPC_ASSERT_CONTEXT(context) ""
55#else
56#define SOPC_ASSERT_CONTEXT(context) __FILE__ ":" SOPC_PP_STR(__LINE__) " => " #context
57#endif
58
62#ifdef WITH_NO_ASSERT
63
64#define SOPC_ASSERT(c) ((void) (c))
65
66#elif defined(WITH_USER_ASSERT)
67
68#define SOPC_ASSERT(c) \
69 do \
70 { \
71 while (!(c)) \
72 { \
73 SOPC_Assert_Failure(SOPC_ASSERT_CONTEXT(c)); \
74 } \
75 } while (0)
76
77#else
78
79#include <assert.h>
80
81#define SOPC_ASSERT assert
82
83#endif
84
95typedef void SOPC_Assert_UserCallback(const char* context);
96
103
110void SOPC_Assert_Failure(const char* context);
111
112#endif /* SOPC_ASSERT_H_ */
void SOPC_Assert_UserCallback(const char *context)
User-defined implementation of Fail-Safe behavior. This method shall be provided when WITH_USER_ASSER...
Definition sopc_assert.h:95
void SOPC_Assert_Failure(const char *context)
Called by SOPC_ASSERT in case of failure.
void SOPC_Assert_Set_UserCallback(SOPC_Assert_UserCallback *callback)
Define the user event to call in case of Assert failure.