直接上代码
https://bbs.csdn.net/topics/340158940
参考问答
#include <stdio.h>
struct demo2{
};
struct demo{
int b;
int c;
int a;
};
typedef struct
{
unsigned long dwFreq;
unsigned char afclocked;
unsigned char ucSndsys;
}ProgInfo;
#define offsetof(type, field) (long)&(((type*)0)->field)
int main() {
printf("%d\n", offsetof(ProgInfo, ucSndsys));
printf("%ld\n",(size_t)(&((struct demo*)0)->a));
return 0;
}