MPLABĀ® Harmony Graphics Suite
legato_error.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
24 /*******************************************************************************
25  Module for Microchip Graphics Library - Legato User Interface Library
26 
27  Company:
28  Microchip Technology Inc.
29 
30  File Name:
31  legato_error.h
32 
33  Summary:
34  Defines library assert macros.
35 
36  Description:
37  Defines library assert macros.
38 *******************************************************************************/
39 
46 #ifndef LE_ERROR_H
47 #define LE_ERROR_H
48 
50 
51 // *****************************************************************************
52 // *****************************************************************************
53 // Section: Data Types and Constants
54 // *****************************************************************************
55 // *****************************************************************************
56 
57 #if LE_ASSERT_ENABLE == 1
58 //#include <assert.h>
59 #endif
60 
61 /* controls whether library-wide asserts are enabled */
62 #if LE_ASSERT_ENABLE == 1
63 //#define LE_ASSERT(val) assert(val)
64 //#define LE_ASSERT_MSG(val, msg) for ( ; !(val) ; assert(val) ) { leSetErrorMessage(msg); }
65 //#define LE_ASSERT_VAR(val, fmt, ...) for ( ; !(val) ; assert(val) ) { leSprintfErrorMessage(fmt, __VA_ARGS__); }
66 #define LE_ASSERT(val) if((val) == 0) { leAssert(); }
67 #define LE_ASSERT_MSG(val, msg) if((val) == 0) { leSetErrorMessage(msg); }
68 #define LE_ASSERT_VAR(val, fmt, ...) if((val) == 0) { leSprintfErrorMessage(fmt, __VA_ARGS__); }
69 #else
70 #define LE_ASSERT(val)
71 #define LE_ASSERT_MSG(val, msg)
72 #define LE_ASSERT_VAR(val, fmt, ...)
73 #endif
74 
75 #define LE_ASSERT_THIS() LE_ASSERT_MSG(_this != NULL, "'this' pointer is null")
76 
77 // *****************************************************************************
78 // *****************************************************************************
79 // Section: Routines
80 // *****************************************************************************
81 // *****************************************************************************
82 
83 #if LE_ASSERT_ENABLE == 1
84 
94 void leAssert();
95 
96 // *****************************************************************************
97 /* Function:
98  const char* leGetErrorMessage()
99 
100  Summary:
101  Gets the library global error message.
102 
103  Description:
104  Gets the library global error message.
105 
106  Parameters:
107 
108  Returns:
109  const char* msg - the error message
110 
111  Remarks:
112 
113 */
123 const char* leGetErrorMessage();
124 
125 // *****************************************************************************
126 /* Function:
127  void leSetErrorMessage(const char* msg)
128 
129  Summary:
130  Sets the library global error message.
131 
132  Description:
133  Sets the library global error message.
134 
135  Parameters:
136  const char* msg - the error message
137 
138  Returns:
139 
140  Remarks:
141 
142 */
154 void leSetErrorMessage(const char* msg);
155 
156 // *****************************************************************************
157 /* Function:
158  void leSetErrorMessage(const char* fmt, ...)
159 
160  Summary:
161  Sets the library global error message using a formatted string.
162 
163  Description:
164  Sets the library global error message using a formatted string.
165 
166  Parameters:
167  const char* fmt - the formatted error message string
168  varargs - the arguments to the formatted string
169 
170  Returns:
171 
172  Remarks:
173 
174 */
187 void leSprintfErrorMessage(const char* fmt, ...);
188 
189 #endif
190 
191 #endif /* LE_ERROR_H */
legato_error.h
Error functions, macros and definitions.
legato_common.h
Common macros and definitions used by Legato.