已知结构体成员地址,计算出结构体变量地址

image

点击查看代码
/**
 * rt_container_of - return the member address of ptr, if the type of ptr is the
 * struct type.
 */
#define rt_container_of(ptr, type, member) \
    ((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))



image

image

posted @ 2023-09-13 10:02  我爱茜茜公主  阅读(21)  评论(0)    收藏  举报