S
Sekhar
While going through one discussion forum i come across one interesting
query.
Without creating an object how to find the offset of a structure member
variable.
Something like
struct A
{
double i;
int j;
}
OFFSETOF(A, j) should return offset of member variable j.
I come across one standard function in stddef.h where this is already
defined as
#define offsetof(s,m) (size_t)&(((s *)0)->m)
and is working fine and the above snippet is giving me 8 on a VC++ 6.0
compiler
Can anyone shed some light of how this is working.
Thanks and Regards
Sujil C
query.
Without creating an object how to find the offset of a structure member
variable.
Something like
struct A
{
double i;
int j;
}
OFFSETOF(A, j) should return offset of member variable j.
I come across one standard function in stddef.h where this is already
defined as
#define offsetof(s,m) (size_t)&(((s *)0)->m)
and is working fine and the above snippet is giving me 8 on a VC++ 6.0
compiler
Can anyone shed some light of how this is working.
Thanks and Regards
Sujil C