On Mon, Mar 11, 2013 at 11:26:57PM +0100, Darius Blaszyk wrote: > > > I'm stuck porting a macro from C. Below is the original define. The > part I'm struggeling with is the right most part after the - sign. > > > #define GETNEXT(x) ((LList *)(((char *) x) - ((char *) & (((LList > *)0)^.next))))
I'm assuming that the "^." should be "->", in which case the last bit is doing the same as the offsetof() macro. So the macro is subtracting the offset in bytes of the "next" member of the LList struct from x, then casting it to (LList *). I'd wager that the GETNEXT() isn't actually doing what it says, but something more like container_of() (because it's _subtracting_ the offset). I may be wrong, though, do you have an example of its usage? Henry _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal