Zero  0.1.0
w_error.h
Go to the documentation of this file.
1 #ifndef __W_ERROR_H
2 #define __W_ERROR_H
3 /*
4  * (c) Copyright 2014, Hewlett-Packard Development Company, LP
5  */
6 
37 #define X(a, b) a,
38 
46 
47 #include "w_error_xmacro.h"
48 
50  w_error_count
51 };
52 #undef X
53 
54 // A bit tricky to get "a" from a in C macro.
55 #define X_QUOTE(str) #str
56 #define X_EXPAND_AND_QUOTE(str) X_QUOTE(str)
57 #define X(a, b) case a: return X_EXPAND_AND_QUOTE(a);
58 
63 inline const char* w_error_name(w_error_codes error_code) {
64  switch (error_code) {
65  case w_error_ok:
66  return "w_error_ok";
67  case w_error_count:
68  return "w_error_count";
69 
70 #include "w_error_xmacro.h"
71  }
72  return "Unexpected error code";
73 };
74 #undef X
75 #undef X_EXPAND_AND_QUOTE
76 #undef X_QUOTE
77 
78 #define X(a, b) case a: return b;
79 
84 inline const char* w_error_message(w_error_codes error_code) {
85  switch (error_code) {
86  case w_error_ok:
87  return "no_error";
88  case w_error_count:
89  return "error-count";
90 
91 #include "w_error_xmacro.h"
92  }
93  return "Unexpected error code";
94 };
95 #undef X
96 
97 #endif // __W_ERROR_H
Error code/message definition in X-Macro style.
w_error_codes
Enum of error codes defined in w_error_xmacro.h.
Definition: w_error.h:43
Definition: w_error.h:45