<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Verdana,Geneva,sans-serif'>
<p>Henry Vermaak schreef op 12 mrt '13:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<pre>On Mon, Mar 11, 2013 at 11:26:57PM +0100, Darius Blaszyk wrote:</pre>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">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))))</blockquote>
<pre>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  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
<p>BTW, you were right. The ^ was indeed a ->, but got replaced in the porting process.<br /><br />Regards, Darius</p>
<br />
<div> </div>
</body></html>