+ -
当前位置:首页 → 问答吧 → 初学者购买哪种开发板,TQ2440和友善之臂mini2440哪个更适合初学者?

初学者购买哪种开发板,TQ2440和友善之臂mini2440哪个更适合初学者?

时间:2010-10-22

来源:互联网

宏定义如下:
/**
* 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); \
(type *)( (char *)__mptr - offsetof(type,member) );})

为什么要定义一个临时变量__mptr,为什么不直接作如下定义?
#define container_of(ptr,type,member) (type *)( (char *)(ptr) - offsetof(type,member) )

作者: 秦 俑   发布时间: 2010-10-22