MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
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 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 // *****************************************************************************
56 // *****************************************************************************
57 // Section: Data Types and Constants
58 // *****************************************************************************
59 // *****************************************************************************
60 
61 #if LE_ASSERT_ENABLE == 1
62 //#include <assert.h>
63 #endif
64 
65 /* controls whether library-wide asserts are enabled */
66 #if LE_ASSERT_ENABLE == 1
67 //#define LE_ASSERT(val) assert(val)
68 //#define LE_ASSERT_MSG(val, msg) for ( ; !(val) ; assert(val) ) { leSetErrorMessage(msg); }
69 //#define LE_ASSERT_VAR(val, fmt, ...) for ( ; !(val) ; assert(val) ) { leSprintfErrorMessage(fmt, __VA_ARGS__); }
70 #define LE_ASSERT(val) if((val) == 0) { leAssert(); }
71 #define LE_ASSERT_MSG(val, msg) if((val) == 0) { leSetErrorMessage(msg); }
72 #define LE_ASSERT_VAR(val, fmt, ...) if((val) == 0) { leSprintfErrorMessage(fmt, __VA_ARGS__); }
73 #else
74 #define LE_ASSERT(val)
75 #define LE_ASSERT_MSG(val, msg)
76 #define LE_ASSERT_VAR(val, fmt, ...)
77 #endif
78 
79 #define LE_ASSERT_THIS() LE_ASSERT_MSG(_this != NULL, "'this' pointer is null")
80 
81 // *****************************************************************************
82 // *****************************************************************************
83 // Section: Routines
84 // *****************************************************************************
85 // *****************************************************************************
86 
87 #if LE_ASSERT_ENABLE == 1
88 
98 void leAssert(void) __attribute__ ((noreturn));;
99 
100 // *****************************************************************************
101 /* Function:
102  const char* leGetErrorMessage()
103 
104  Summary:
105  Gets the library global error message.
106 
107  Description:
108  Gets the library global error message.
109 
110  Parameters:
111 
112  Returns:
113  const char* msg - the error message
114 
115  Remarks:
116 
117 */
127 const char* leGetErrorMessage(void);
128 
129 // *****************************************************************************
130 /* Function:
131  void leSetErrorMessage(const char* msg)
132 
133  Summary:
134  Sets the library global error message.
135 
136  Description:
137  Sets the library global error message.
138 
139  Parameters:
140  const char* msg - the error message
141 
142  Returns:
143 
144  Remarks:
145 
146 */
158 void leSetErrorMessage(const char* msg);
159 
160 // *****************************************************************************
161 /* Function:
162  void leSetErrorMessage(const char* fmt, ...)
163 
164  Summary:
165  Sets the library global error message using a formatted string.
166 
167  Description:
168  Sets the library global error message using a formatted string.
169 
170  Parameters:
171  const char* fmt - the formatted error message string
172  varargs - the arguments to the formatted string
173 
174  Returns:
175 
176  Remarks:
177 
178 */
191 void leSprintfErrorMessage(const char* fmt, ...) __attribute__ ((noreturn));;
192 
193 #endif
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif /* LE_ERROR_H */
Common macros and definitions used by Legato.