From: peter <lifulong2c2i2c@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Question with "container_of(ptr, type, member)"
Date: Tue, 30 Aug 2011 18:44:59 +0800 [thread overview]
Message-ID: <1314701099.1728.6.camel@peter-2ci2c> (raw)
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~)
next reply other threads:[~2011-08-30 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-30 10:44 peter [this message]
2011-08-30 23:14 ` Question with "container_of(ptr, type, member)" Ryan Mallon
2011-08-31 0:52 ` peter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1314701099.1728.6.camel@peter-2ci2c \
--to=lifulong2c2i2c@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.