]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
macro: add voffsetof() helper, that operates like offsetof() but on variables
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Oct 2024 16:00:31 +0000 (18:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 11 Oct 2024 08:41:06 +0000 (10:41 +0200)
src/fundamental/macro-fundamental.h

index 913c8b253c67fe68b58bf388a54821d18203d329..7b7973232626e592d5c3b7f66bc1574ba17f9ae0 100644 (file)
@@ -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 = ({                   \