G
Generic Usenet Account
I have written a small macro that provides the relative offset of any
field within a structure. Here it goes:
#define RELATIVE_OFFSET(a,b) \
{ \
cout << "The relative offset of the " \
<< strchr(#b, '.') + 1 << " field
is " \
<< (int)&b - (int)&a << endl; \
}
usage:
RELATIVE_OFFSET(structVar, structVar.fieldName);
To all those who believe that inlining is a much better option I say
---- macros ain't that bad.
KP Bhat
field within a structure. Here it goes:
#define RELATIVE_OFFSET(a,b) \
{ \
cout << "The relative offset of the " \
<< strchr(#b, '.') + 1 << " field
is " \
<< (int)&b - (int)&a << endl; \
}
usage:
RELATIVE_OFFSET(structVar, structVar.fieldName);
To all those who believe that inlining is a much better option I say
---- macros ain't that bad.
KP Bhat