1)
#define offsetof(s, m) (size_t)&(((s *)0)->m)
2)
#define OBJECT_HEAD_ADDRESS(ClassName,MemberName,Addre) \
Addre - offsetof(ClassName, MemberName)
C语言中offsetof宏的应用
时间: 2024-11-05 20:29:44
1)
#define offsetof(s, m) (size_t)&(((s *)0)->m)
2)
#define OBJECT_HEAD_ADDRESS(ClassName,MemberName,Addre) \
Addre - offsetof(ClassName, MemberName)
C语言中offsetof宏的应用