#include "stdafx.h"
#include <iostream>
#define myoffsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define container_of(ptr, type, member) (type *)((char *)ptr - myoffsetof(type, member))
struct S
{
char c;
int i;
double d;
};
int _tmain(int argc, _TCHAR* argv[])
{
S s;
s.c = 'a';
s.i = 3;
s.d = 1.2;
S* p = container_of(&s.d, S, d);
std::cout << p->i << std::endl;
return 0;
}