jamesbon
September 9th, 2010, 07:07 AM
I read
http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
but I was not able to understand what is the meaning of typeof.
Any help would be appreciated.
Specially if you can give some example.
I was going through include/linux/kernel.h
encountered typeof here
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
So I specially want to understand use of typeof with respect to this.
(type *)( (char *)__mptr - offsetof(type,member) );})
http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
but I was not able to understand what is the meaning of typeof.
Any help would be appreciated.
Specially if you can give some example.
I was going through include/linux/kernel.h
encountered typeof here
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
So I specially want to understand use of typeof with respect to this.
(type *)( (char *)__mptr - offsetof(type,member) );})