Add memberof(), split some headers, and slightly simplify code
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.
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_memberandtypeof_memberexist, 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/