> On Jan 6, 2018, at 1:49 PM, Karoly Balogh (Charlie/SGR) 
> <char...@scenergy.dfmk.hu> wrote:
> 
> type
>  PMyStruct = ^TMyStruct;
>  TMyStruct = record
>    some, fields: integer;
>    next: PMyStruct;
>  end;
> 
> function MEMNEXT(x: Pointer): PMyStruct;
> begin
>  MEMNEXT:=PMyStruct(PByte(x)-PByte(@(PMyStruct(nil)^.next)));
> end;

I’m curious about how this is intended to be used. What would the value of x 
be? This looks like a confusing way to write sizeof(TMyStruct) - 
Sizeof(pointer) but I’m confused myself.

Also why does @(PMyStruct(nil)^.next not crash? Dereferencing and taking the 
addressing of a nil pointer sounds like a bad idea.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to