Bootstrap

offsetof宏的实现

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//#define offsetof(cp,p) (size_t)&(((cp*)0)->p)
#define offsetof(StructType, MemberName) (size_t)&(((StructType *)0)->MemberName)
struct S 
{
	char a;
	int b;
}s;
int main()
{   
	
	printf("%d", offsetof(struct S,b));
	return 0;
}

;