CJOSE  0.4.1
error.h
Go to the documentation of this file.
1 
11 #ifndef CJOSE_ERROR_H
12 #define CJOSE_ERROR_H
13 
14 #ifdef __cplusplus
15 extern "C"
16 {
17 #endif
18 
19 
28 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
29 # define GCC_END_IGNORED_WARNING _Pragma("GCC diagnostic pop")
30 
31 # define GCC_BEGIN_IGNORED_WARNING_ADDRESS \
32  _Pragma("GCC diagnostic push"); \
33  _Pragma("GCC diagnostic ignored \"-Waddress\"")
34 # define GCC_END_IGNORED_WARNING_ADDRESS GCC_END_IGNORED_WARNING
35 #else
36 # define GCC_BEGIN_IGNORED_WARNING_ADDRESS
37 # define GCC_END_IGNORED_WARNING_ADDRESS
38 #endif /* defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 5) */
39 
40 
44 typedef enum
45 {
48 
51 
54 
57 
60 
62 
63 
70 typedef struct
71 {
73  cjose_errcode code;
75  const char * message;
76 
79  const char * function;
80 
82  const char * file;
83 
85  unsigned long line;
86 
87 } cjose_err;
88 
89 
96 const char * cjose_err_message(cjose_errcode code);
97 
98 
107 #define CJOSE_ERROR(err, errcode) \
108  GCC_BEGIN_IGNORED_WARNING_ADDRESS \
109  if ((err) != NULL && (errcode) != CJOSE_ERR_NONE) \
110  { \
111  (err)->code = (errcode); \
112  (err)->message = cjose_err_message((errcode)); \
113  (err)->function = __func__; \
114  (err)->file = __FILE__; \
115  (err)->line = __LINE__; \
116  } \
117  GCC_END_IGNORED_WARNING_ADDRESS
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif /* CJOSE_ERROR_H */
cjose_errcode code
Definition: error.h:73
const char * cjose_err_message(cjose_errcode code)
Definition: error.h:53
Definition: error.h:59
const char * file
Definition: error.h:82
Definition: error.h:70
cjose_errcode
Definition: error.h:44
const char * message
Definition: error.h:75
Definition: error.h:56
Definition: error.h:47
unsigned long line
Definition: error.h:85
Definition: error.h:50