[fpc-pascal] Pointer question

Hairy Pixels genericptr at gmail.com
Fri Aug 11 18:56:31 CEST 2023



> On Aug 10, 2023, at 11:37 PM, Michael Van Canneyt via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> This is a very dirty trick to get the offset of a field in a record.
> 
> Note that you're not dereferencing a type but a variable of type TAlignCheck located
> at memory address zero. The address of w (this is what the expression is
> doing) is then the offset of w in the record.
> 
> It's probably more clear if you write it as
> p := @(TAlignCheck(nil^).w);

where is the variable located in this expression? It can't be nil can it?

Sounds like we need a compiler intrinsic to get the field address because that syntax is kind of crazy. :)

Regards,
Ryan Joseph



More information about the fpc-pascal mailing list