首页 > 系统服务 > 详细

(六)linux内核中的offsetof与container_of宏

时间:2018-10-26 23:44:06      阅读:213      评论:0      收藏:0      [点我收藏+]

参考:

#define offsetof(type, member) (size_t)&(((type*)0)->member)


#define container_of(ptr, type, member) ({      const typeof( ((type *)0)->member ) *__mptr = (ptr);      (type *)( (char *)__mptr - offsetof(type,member) );})

(六)linux内核中的offsetof与container_of宏

原文:https://www.cnblogs.com/walkinginthesun/p/9858813.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!