Skip to contentSkip to conversation

Add memberof(), split some headers, and slightly simplify code

PATCH Alexey Dobriyan 2 participants 2 messages Nov 19, 2021

lore
Share & tools
lore
#0 lore raw

Review

Quoted 3 lines
(quoted diff) +2 -0
+#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.

#1 lore raw

Hi Alexey,

Quoted 10 lines · Alexey Dobriyan

Review

Quoted 3 lines
(quoted diff) +2 -0
+#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

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