From: Lennart Poettering Date: Wed, 9 Oct 2024 16:00:31 +0000 (+0200) Subject: macro: add voffsetof() helper, that operates like offsetof() but on variables X-Git-Tag: v257-rc1~258^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=44fd4548b56865929a32bfdaf386e27d2ba864d4;p=thirdparty%2Fsystemd.git macro: add voffsetof() helper, that operates like offsetof() but on variables --- diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 913c8b253c6..7b797323262 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -549,6 +549,7 @@ static inline uint64_t ALIGN_OFFSET_U64(uint64_t l, uint64_t ali) { #define sizeof_field(struct_type, member) sizeof(((struct_type *) 0)->member) #define endoffsetof_field(struct_type, member) (offsetof(struct_type, member) + sizeof_field(struct_type, member)) +#define voffsetof(v, member) offsetof(typeof(v), member) #define _FOREACH_ARRAY(i, array, num, m, end) \ for (typeof(array[0]) *i = (array), *end = ({ \