[fpc-pascal] Pointer question
Nikolay Nikolov
nickysn at gmail.com
Fri Aug 11 12:12:35 CEST 2023
On 8/11/23 01:23, Hairy Pixels via fpc-pascal wrote:
>
>> On Aug 10, 2023, at 2:18 PM, Michael Van Canneyt via fpc-pascal<fpc-pascal at lists.freepascal.org> wrote:
>>
>> https://www.freepascal.org/docs-html/current/ref/refse15.html#x42-620003.4
> This document doesn't really do a great enumerating all the operators so I'm not sure if the list is complete. I think the list is:
>
> var
> p: pointer;
> i: ^Integer;
> v: Integer;
> begin
> // 1) increment
> p := p + 1;
> inc(p);
>
> // 2) increment
> p := p - 1;
> dec(p);
>
> // 3) difference
> v := p - p;
>
> // 4) subscript (inc and dereference in one step)
> v := i[1];
>
>
> #4 was not in the list for example so I wonder what others exist.
That is not true. Read that document again and focus on the part that
starts with "Remark Free Pascal treats pointers much the same way as C
does. This means that a pointer to some type can be treated as being an
array of this type."
In fact, Free Pascal's documentation and exactly this page is how I
learned about this feature a long time ago.
Nikolay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230811/b654fce9/attachment.htm>
More information about the fpc-pascal
mailing list