-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmacroutils.h
More file actions
19 lines (17 loc) · 749 Bytes
/
macroutils.h
File metadata and controls
19 lines (17 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* General-purpose macro utilities
*/
#define arr_len(array) (sizeof (array) / sizeof (*(array)))
#define arr_foreach(var, arr) \
for (long keep = 1, cnt = 0, size = arr_len(arr); \
keep && (cnt < size); keep = !keep, cnt++) \
for (typeof(*(arr)) var = (arr)[cnt]; keep; keep = !keep)
#define except(condition, seterr, errptr, gotoptr) \
{ \
bool cond = (condition); \
if (cond) { \
errptr = (seterr); \
goto gotoptr; \
} \
cond; \
}