您的位置:首页 > 其它

计算结构体基地址的宏定义

2017-06-22 17:43 190 查看
前言:2014-08-06记录在hi baidu上,现在移过来

winnt.h中定义的宏

//
// Calculate the address of the base of the structure given its type, and an
// address of a field within the structure.
//
#define CONTAINING_RECORD(address, type, field) ((type *)( \

(PCHAR)(address) - \

(ULONG_PTR)(&((type *)0)->field)))


(ULONG_PTR)(&((type*)0)->field) 计算field相对于基地址的偏移
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  结构