lkml.org 
[lkml]   [2011]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectQuestion with "container_of(ptr, type, member)"
From
Date
I have a question about the macro " container_of(ptr, type, member) "
I can write it as this,
#define container_of(ptr, type, member) ({ \
(type *) ((char *) ptr - offset_of(type, member)); \
})
It can act the same as
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
So why we don't use the first one ?
Thanks for your answer.
(I am a kernel newbie ,and sorry for my poor english~)




\
 
 \ /
  Last update: 2011-08-30 12:47    [W:0.038 / U:1.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site