[fpc-pascal] Porting C macro

Flávio Etrusco flavio.etrusco at gmail.com
Tue Mar 12 00:00:41 CET 2013


On 3/11/13, Darius Blaszyk <dhkblaszyk at zeelandnet.nl> 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))))
>
> Does anyone know what is meant with the define?
> Obviously LList is a linked list struct that has a prev and next
> variable. But what does the & and 0 mean?
>
> Appreciate any
> help.
>
> Regards, Darius

AFAICS they mean "address" and "nil", respectively, so that part will
return the offset of "next" inside and item of LList.

-Flávio


-Flávio



More information about the fpc-pascal mailing list