#include <stdio.h>
#define abc(s,m) (size_t)&(((s*)0)->m)
#define bcd(ptr, type, member) ({const typeof(((type*)0)->member)* __mptr=(ptr);\
(type*)((char*)__mptr-abc(type,member));})
struct test{
int a;
char b;
long t;
};
int main()
{
struct test *p;
struct test m;
m.a = -1;
m.t = 37;
p = bcd(&(m.t), struct test, t);
printf("%d\n", p->a);
return 0;
}
#define abc(s,m) (size_t)&(((s*)0)->m)
#define bcd(ptr, type, member) ({const typeof(((type*)0)->member)* __mptr=(ptr);\
(type*)((char*)__mptr-abc(type,member));})
struct test{
int a;
char b;
long t;
};
int main()
{
struct test *p;
struct test m;
m.a = -1;
m.t = 37;
p = bcd(&(m.t), struct test, t);
printf("%d\n", p->a);
return 0;
}