-
Notifications
You must be signed in to change notification settings - Fork 0
/
cm_debug.h
37 lines (33 loc) · 1.35 KB
/
cm_debug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* @file cm_debug.c
* @brief A common way of error reporting and debugging messages
* @detail This section handles all the error reporting
* features in all sections. Using this section
* the programmer can debug the code (finding the
* line number, section, function name). To enable
* this feature programmer need to enable 'CM_DEBUG_'
* at compile time.
*/
#ifndef CM_DEBUG_H
#define CM_DEBUG_H
#ifdef CM_DEBUG_
extern void cm_error(const char *section, const char *func, int line_num,
const char *err_str, ...);
extern void cm_warn(const char *section, const char *func, int line_num,
const char *warn_str, ...);
extern void debug_msg(const char *section, const char *func, int line_num,
const char *debug_msg, ...);
#else
extern void cm_error(const char *err_str, ...);
extern void cm_warn(const char *warn_str, ...);
#endif
#ifdef CM_DEBUG_
#define CM_ERROR(ER_FRMT, ...) cm_error(__FILE__, __func__, __LINE__, ER_FRMT, ##__VA_ARGS__)
#define CM_WARN(ER_FRMT, ...) cm_warn(__FILE__, __func__, __LINE__, ER_FRMT, ##__VA_ARGS__)
#define DEBUG_MSG(DEBUG_FRMT, ...) debug_msg(__FILE__, __func__, __LINE__, DEBUG_FRMT, ##__VA_ARGS__)
#else
#define CM_ERROR(ER_FRMT, ...) cm_error(ER_FRMT, ##__VA_ARGS__)
#define CM_WARN(ER_FRMT, ...) cm_warn(ER_FRMT, ##__VA_ARGS__)
#define DEBUG_MSG(x) ; /* suppress the debug msg */
#endif
#endif