结构体能存放数据
结构体嵌入链表能够让数据串联成为整体
如何通过结构体的链表找到对应结构体
container_of宏定义
/*#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})*/
测试代码
struct test *w=init();
printf("%p\n",w);
struct test *n=container_of(&w->num,trst,num); /*typedef struct test{}; trst*/
printf("%p\n",n);
输出结构相等