#include <stdio.h>
 #include <stddef.h>
 // 需要包含 <stddef.h> 否则会有以下错误, 是因为找不到offsetof()而引起
 //    printf("age offset:%d\n",offsetof(Persion,age));
 //main.cpp|11 col 43| error: expected primary-expression before ‘,’ token
 typedef struct Persion {
    char name[50];
    char id[50];
    int age;
 }Persion;
 // offsetof 是个啥? 它是个宏,
 // 在emacs中用tag 命令查找,找到的是在/usr/include/slang.h中定义的宏
 // #ifndef offsetof
 // # define offsetof(T,F) ((unsigned int)((char *)&((T *)0L)->F - (char *)0L))
 // #endif
 // 但这是不准确的, 我们用gcc 预处理重新查找一下, 发现它是一个内部实现
 //在/usr/include/stddef.h中 406行有定义,是个宏
 //#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
 // __builtin_offsetof 就依赖于gcc 的内部实现了, 不过不管怎么说,它还是 &((TYPE *)0L)->MEBBER
int main()
 {
     printf("age offset:%ld\n",offsetof(Persion,age));
     return 0;
 }
//总结: linux 应用中 offsetof 是在stddef.h 中定义的一个宏
 //#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)