ReactOS  0.4.13-dev-651-g5dbc677
debug.h
Go to the documentation of this file.
1 /*
2  debug.h:
3  if DEBUG defined: debugging macro fprintf wrappers
4  else: macros defined to do nothing
5  That saves typing #ifdef DEBUG all the time and still preserves
6  lean code without debugging.
7 
8  public domain (or LGPL / GPL, if you like that more;-)
9  generated by debugdef.pl, what was
10  trivially written by Thomas Orgis <thomas@orgis.org>
11 */
12 
13 #include "config.h"
14 
15 /*
16  I could do that with variadic macros available:
17  #define sdebug(me, s) fprintf(stderr, "[location] " s "\n")
18  #define debug(me, s, ...) fprintf(stderr, "[location] " s "}n", __VA_ARGS__)
19 
20  Variadic macros are a C99 feature...
21  Now just predefining stuff non-variadic for up to 15 arguments.
22  It's cumbersome to have them all with different names, though...
23 */
24 
25 #ifdef ME
26 #define DBGPRFX ME": "
27 #else
28 #define DBGPRFX ""
29 #endif
30 
31 #ifdef DEBUG
32 
33 #include <stdio.h>
34 #define debug(s) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__)
35 #define debug1(s, a) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a)
36 #define debug2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b)
37 #define debug3(s, a, b, c) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c)
38 #define debug4(s, a, b, c, d) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d)
39 #define debug5(s, a, b, c, d, e) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e)
40 #define debug6(s, a, b, c, d, e, f) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f)
41 #define debug7(s, a, b, c, d, e, f, g) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g)
42 #define debug8(s, a, b, c, d, e, f, g, h) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
43 #define debug9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
44 #define debug10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
45 #define debug11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
46 #define debug12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
47 #define debug13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
48 #define debug14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
49 #define debug15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
50 #else
51 #define debug(s)
52 #define debug1(s, a)
53 #define debug2(s, a, b)
54 #define debug3(s, a, b, c)
55 #define debug4(s, a, b, c, d)
56 #define debug5(s, a, b, c, d, e)
57 #define debug6(s, a, b, c, d, e, f)
58 #define debug7(s, a, b, c, d, e, f, g)
59 #define debug8(s, a, b, c, d, e, f, g, h)
60 #define debug9(s, a, b, c, d, e, f, g, h, i)
61 #define debug10(s, a, b, c, d, e, f, g, h, i, j)
62 #define debug11(s, a, b, c, d, e, f, g, h, i, j, k)
63 #define debug12(s, a, b, c, d, e, f, g, h, i, j, k, l)
64 #define debug13(s, a, b, c, d, e, f, g, h, i, j, k, l, m)
65 #define debug14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
66 #define debug15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
67 #endif
68 
69 /* warning macros also here... */
70 #ifndef NO_WARNING
71 #define warning(s) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__)
72 #define warning1(s, a) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a)
73 #define warning2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b)
74 #define warning3(s, a, b, c) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c)
75 #define warning4(s, a, b, c, d) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d)
76 #define warning5(s, a, b, c, d, e) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e)
77 #define warning6(s, a, b, c, d, e, f) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f)
78 #define warning7(s, a, b, c, d, e, f, g) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g)
79 #define warning8(s, a, b, c, d, e, f, g, h) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
80 #define warning9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
81 #define warning10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
82 #define warning11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
83 #define warning12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
84 #define warning13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
85 #define warning14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
86 #define warning15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
87 #else
88 #define warning(s)
89 #define warning1(s, a)
90 #define warning2(s, a, b)
91 #define warning3(s, a, b, c)
92 #define warning4(s, a, b, c, d)
93 #define warning5(s, a, b, c, d, e)
94 #define warning6(s, a, b, c, d, e, f)
95 #define warning7(s, a, b, c, d, e, f, g)
96 #define warning8(s, a, b, c, d, e, f, g, h)
97 #define warning9(s, a, b, c, d, e, f, g, h, i)
98 #define warning10(s, a, b, c, d, e, f, g, h, i, j)
99 #define warning11(s, a, b, c, d, e, f, g, h, i, j, k)
100 #define warning12(s, a, b, c, d, e, f, g, h, i, j, k, l)
101 #define warning13(s, a, b, c, d, e, f, g, h, i, j, k, l, m)
102 #define warning14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
103 #define warning15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
104 #endif
105 
106 /* error macros also here... */
107 #ifndef NO_ERROR
108 #define error(s) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__)
109 #define error1(s, a) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a)
110 #define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
111 #define error3(s, a, b, c) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c)
112 #define error4(s, a, b, c, d) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d)
113 #define error5(s, a, b, c, d, e) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e)
114 #define error6(s, a, b, c, d, e, f) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f)
115 #define error7(s, a, b, c, d, e, f, g) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g)
116 #define error8(s, a, b, c, d, e, f, g, h) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
117 #define error9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
118 #define error10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
119 #define error11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
120 #define error12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
121 #define error13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
122 #define error14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
123 #define error15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
124 #else
125 #define error(s)
126 #define error1(s, a)
127 #define error2(s, a, b)
128 #define error3(s, a, b, c)
129 #define error4(s, a, b, c, d)
130 #define error5(s, a, b, c, d, e)
131 #define error6(s, a, b, c, d, e, f)
132 #define error7(s, a, b, c, d, e, f, g)
133 #define error8(s, a, b, c, d, e, f, g, h)
134 #define error9(s, a, b, c, d, e, f, g, h, i)
135 #define error10(s, a, b, c, d, e, f, g, h, i, j)
136 #define error11(s, a, b, c, d, e, f, g, h, i, j, k)
137 #define error12(s, a, b, c, d, e, f, g, h, i, j, k, l)
138 #define error13(s, a, b, c, d, e, f, g, h, i, j, k, l, m)
139 #define error14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
140 #define error15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
141 #endif
142 
143 /* ereturn macros also here... */
144 #ifndef NO_ERETURN
145 #define ereturn(rv, s) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__); return rv; }while(0)
146 #define ereturn1(rv, s, a) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a); return rv; }while(0)
147 #define ereturn2(rv, s, a, b) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b); return rv; }while(0)
148 #define ereturn3(rv, s, a, b, c) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c); return rv; }while(0)
149 #define ereturn4(rv, s, a, b, c, d) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d); return rv; }while(0)
150 #define ereturn5(rv, s, a, b, c, d, e) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e); return rv; }while(0)
151 #define ereturn6(rv, s, a, b, c, d, e, f) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f); return rv; }while(0)
152 #define ereturn7(rv, s, a, b, c, d, e, f, g) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g); return rv; }while(0)
153 #define ereturn8(rv, s, a, b, c, d, e, f, g, h) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h); return rv; }while(0)
154 #define ereturn9(rv, s, a, b, c, d, e, f, g, h, i) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i); return rv; }while(0)
155 #define ereturn10(rv, s, a, b, c, d, e, f, g, h, i, j) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j); return rv; }while(0)
156 #define ereturn11(rv, s, a, b, c, d, e, f, g, h, i, j, k) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k); return rv; }while(0)
157 #define ereturn12(rv, s, a, b, c, d, e, f, g, h, i, j, k, l) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l); return rv; }while(0)
158 #define ereturn13(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m); return rv; }while(0)
159 #define ereturn14(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n); return rv; }while(0)
160 #define ereturn15(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); return rv; }while(0)
161 #else
162 #define ereturn(rv, s) return rv
163 #define ereturn1(rv, s, a) return rv
164 #define ereturn2(rv, s, a, b) return rv
165 #define ereturn3(rv, s, a, b, c) return rv
166 #define ereturn4(rv, s, a, b, c, d) return rv
167 #define ereturn5(rv, s, a, b, c, d, e) return rv
168 #define ereturn6(rv, s, a, b, c, d, e, f) return rv
169 #define ereturn7(rv, s, a, b, c, d, e, f, g) return rv
170 #define ereturn8(rv, s, a, b, c, d, e, f, g, h) return rv
171 #define ereturn9(rv, s, a, b, c, d, e, f, g, h, i) return rv
172 #define ereturn10(rv, s, a, b, c, d, e, f, g, h, i, j) return rv
173 #define ereturn11(rv, s, a, b, c, d, e, f, g, h, i, j, k) return rv
174 #define ereturn12(rv, s, a, b, c, d, e, f, g, h, i, j, k, l) return rv
175 #define ereturn13(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m) return rv
176 #define ereturn14(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) return rv
177 #define ereturn15(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) return rv
178 #endif