On 11.10.2023 14:46, Nicola Vetrini wrote: > --- a/xen/include/xen/compiler.h > +++ b/xen/include/xen/compiler.h > @@ -109,13 +109,16 @@ > > #define offsetof(a,b) __builtin_offsetof(a,b) > > +/* Access the field of structure type, without defining a local variable */ > +#define access_field(type, member) (((type *)NULL)->member)
This is not a field access, so I consider the macro misnamed. Question is whether such a helper macro is needed in the first place. > +#define typeof_field(type, member) typeof(access_field(type, member)) If this needs adding, it wants to come ... > /** > * sizeof_field(TYPE, MEMBER) > * > * @TYPE: The structure containing the field of interest > * @MEMBER: The field to return the size of > */ > -#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) > +#define sizeof_field(TYPE, MEMBER) sizeof(access_field(TYPE, MEMBER)) ... with a commend similar as this one has. (Or the commend could be slightly altered to cover both). Further, if fiddling with these: Wouldn't they better move to macros.h? Jan