[fpc-pascal] Pointer question

Hairy Pixels genericptr at gmail.com
Thu Aug 10 18:29:17 CEST 2023



> On Aug 9, 2023, at 4:37 PM, Tomas Hajny via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> No, the offset is not a memory address but just a number of bytes (which is also the reason why you cannot add the pointers together, but you can add a number to a pointer. As an example, you could use this operation to find out the exact alignment of fields within a record (to check whether there's some padding inserted between them) - e.g. if you aren't sure what alignment directive was used for compiling a unit declaring the structure, or to understand the compiler behaviour for a particuler alignment directive..

OK I understand now. It's basically an implicit cast to integer. There may have been historical reasons for this but I don't understand why you wouldn't just cast explicitly. Same goes for companions operators I think. I'd say it's one of the more confusion parts of the syntax actually.

Regards,
Ryan Joseph



More information about the fpc-pascal mailing list