Possible Duplicate:
offsetof at compile time
How can I find the offset of a member within a struct in C? For example, how can I find the offset of t in this struct:
struct test
{
int a;
int b;
struct test* t;
int c;
};
Possible Duplicate:
offsetof at compile time
How can I find the offset of a member within a struct in C? For example, how can I find the offset of t in this struct:
struct test
{
int a;
int b;
struct test* t;
int c;
};
Use the offsetof() macro from stddef.h: offsetof(struct test, t). (ideone example)