Forum > General

how works somethink like @identifier^ ?



i am not very used to pointers, and I found a piece of code with this :


For what I understood on pointers, for me

@identifier^ = identifier

I have a variable, I get its address with @ (so now I have a pointer to it), then I dereference this pointer with ^ , so I get the identifier value.

But I have the feeling it it not the case...

It depends on operator precedence. Actually I don't remember the relative precedence for "@" and "^", but anyway I think it's a very bad idea to use "@blablabla^".

@identifier = address = (untyped) pointer. When you append the caret symbol (^) what type of var do you expect to find at that address? What you can do is typecast it: identifier := <expected_type>(@identifier);

I would be curious to know if that code you found works and in what compiler.

You will find it many times in comobj.pp file from Freepascal winunits-base package.


[0] Message Index

Go to full version