Re: [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code

From: Alejandro Colomar (man-pages)
Date: Fri Nov 19 2021 - 10:13:35 EST


Hi Alexey,

On 11/19/21 16:07, Alexey Dobriyan wrote:
>> +#define memberof(T, m) (((T *) NULL)->m)
>> +
>> #define typeof_member(T, m) typeof(((T*)0)->m)
>
> No.
>
> Your macro exists already under different name.
>
> sizeof_member and typeof_member exist, you don't anything more.
>

The macro memberof() exists in one file (or 2)
under the name struct_member(), IIRC.

sizeof_member(), which is actually sizeof_field, IIRC,
and typeof_member(),
make use of this construction,
but they unnecessarily repeat it,
and there are other cases where code wants exactly memberof(),
not any of its wrappers.

I think that macro makes a lot of sense.

If you prefer the name struct_member() instead of memberof(),
I'm fine with it.
I just found that name much later than writing memberof(),
and memberof() was more consistent
with the typical naming of xxxof() for similar macros.

Thanks,
Alex

--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/