From: Marc-André Lureau Date: Sun, 17 May 2020 13:25:14 +0000 (+0200) Subject: macro.h: add sizeof_field() helper X-Git-Tag: v246-rc1~207^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaec2d7b9b4756e5600d132e1a179f8bdce99945;p=thirdparty%2Fsystemd.git macro.h: add sizeof_field() helper Similar to kernel FIELD_SIZE() --- diff --git a/src/basic/macro.h b/src/basic/macro.h index b48d3990972..78e4262e41d 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -448,6 +448,8 @@ static inline int __coverity_check_and_return__(int condition) { #define char_array_0(x) x[sizeof(x)-1] = 0; +#define sizeof_field(struct_type, member) sizeof(((struct_type *) 0)->member) + /* Returns the number of chars needed to format variables of the * specified type as a decimal string. Adds in extra space for a * negative '-' prefix (hence works correctly on signed