|
|
|
|
|
by a1369209993
2118 days ago
|
|
That should be: Parent* p = container_of(field,Parent,pa_somefield);
access(p->pa_otherfield);
You'd usually define container_of using subtraction (not negative offset per se): #define container_of(FIELD,TYPE,MEMB) ({ \
const typeof( ((TYPE*)0)->MEMB )* _mptr = (FIELD); \
(TYPE*)( (char*)_mptr - __builtin_offsetof(TYPE,MEMB) ); \
})
but you shouldn't actually be using that directly, because thats what the macro is for. |
|