RKH
rkhassert.h
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH site: http://vortexmakes.com/que-es/
28  * RKH GitHub: https://github.com/vortexmakes/RKH
29  * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30  * e-mail: lf@vortexmakes.com
31  * ---------------------------------------------------------------------------
32  */
33 
60 /* -------------------------- Development history -------------------------- */
61 /*
62  * 2015.10.24 LeFr v2.4.05 Initial version
63  */
64 
65 /* -------------------------------- Authors -------------------------------- */
66 /*
67  * LeFr Leandro Francucci lf@vortexmakes.com
68  */
69 
70 /* --------------------------------- Notes --------------------------------- */
71 /* --------------------------------- Module -------------------------------- */
72 #ifndef __RKHASSERT_H__
73 #define __RKHASSERT_H__
74 
75 /* ----------------------------- Include files ----------------------------- */
76 #include "rkhcfg.h"
77 #include "rkhfwk_module.h"
78 
79 /* ---------------------- External C language linkage ---------------------- */
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 /* --------------------------------- Macros -------------------------------- */
85 #if RKH_CFG_FWK_ASSERT_EN == RKH_ENABLED
129  #define RKH_ASSERT(exp) \
130  if ((exp)) \
131  { \
132  } \
133  else \
134  { \
135  rkh_assert(m_name, __LINE__); \
136  }
137 
151  #define RKH_ALLEGE(exp) RKH_ASSERT(exp)
152 
163  #define RKH_ERROR() rkh_assert(m_name, __LINE__)
164 
165 #else
166  #define RKH_ASSERT(exp) ((void)0)
167  #define RKH_ALLEGE(exp) ((void)(exp))
168  #define RKH_ERROR() ((void)0)
169 #endif
170 
180 #define RKH_REQUIRE(exp) RKH_ASSERT(exp)
181 
191 #define RKH_ENSURE(exp) RKH_ASSERT(exp)
192 
202 #define RKH_INVARIANT(exp) RKH_ASSERT(exp)
203 
204 /* -------------------------------- Constants ------------------------------ */
205 /* ------------------------------- Data types ------------------------------ */
206 /* -------------------------- External variables --------------------------- */
207 /* -------------------------- Function prototypes -------------------------- */
208 #if RKH_CFG_FWK_ASSERT_EN == RKH_ENABLED
263 void rkh_assert(const char *const file, int line);
264 #endif
265 
266 /* -------------------- External C language linkage end -------------------- */
267 #ifdef __cplusplus
268 }
269 #endif
270 
271 /* ------------------------------ Module end ------------------------------- */
272 #endif
273 
274 /* ------------------------------ End of file ------------------------------ */
void rkh_assert(const char *const file, int line)
Callback invoked in case the condition passed to RKH_ASSERT(), RKH_REQUIRE(), RKH_ENSURE(),...
RKH user configurations.
Specifies the macros to identify file modules.