[comp.windows.x] XtOffset implementation problem

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (06/27/90)

[trying to find an XtOffset that works on a certain compiler]
>> #define XtOffset(T,M) (int)(char *)&((T)0)->M
>> #define XtOffset(T,M) ((char *)&((T)0)->M - (char *)0)
>> static int foo;
>> #define XtOffset(T,M) ((char *)&((T)&foo)->M - (char *)&foo)

> I have a litle difficulty understanding these.  Why the `0' following
> `(T)' in the first two, and the `&foo' following `(T)' in the second.

The T argument is expected to be a type (a struct pointer type), not an
object of any sort.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu