Re: Fwd: Question about container_of macro.

Alan Stern <[email protected]> Thu, 17 Jan 2008 14:39:52 -0500 (EST)
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Thu, 17 Jan 2008, Manish Katiyar wrote:

> My question is instead of defining container_of as:
> 
> #define container_of(ptr, type, member) ({ \
>                 const typeof( ((type *)0)->member ) *__mptr = (ptr);
>                 (type *)( (char *)__mptr - offsetof(type,member) );})
> 
> 
> Why won't this simply work :
> 
> #define container_of(ptr, type, member) ({ \
>                         (type *)( (char *)(ptr) - offsetof(type,member) );})

Indeed, or even this:

#define container_of(ptr, type, member) \
			((type *) ((char *)(ptr) - offsetof(type,member)))

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel