defs.h: add offsetofend macro
Analogous to offsetof but returns structure offset after the specified field. Useful for checking whether specific field is present in obtained data or specifying amount of data to copy based on the (last) field needed. * defs.h (offsetofend): New macro.
This commit is contained in:
parent
d212c95b84
commit
6e6c11d9dd
5
defs.h
5
defs.h
@ -68,6 +68,11 @@ const char *strerror(int);
|
|||||||
extern char *stpcpy(char *dst, const char *src);
|
extern char *stpcpy(char *dst, const char *src);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef offsetofend
|
||||||
|
# define offsetofend(type, member) \
|
||||||
|
(offsetof(type, member) + sizeof(((type *)NULL)->member))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
/* macros */
|
/* macros */
|
||||||
|
Loading…
Reference in New Issue
Block a user