Sign in Join
Wiki copytemporary

Revision 1 of 4, by WikiArchive on 11-4-2026. The page as it is now.

@

<div style="float:left; margin: 0 25px 20px 0; padding:50px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">

@

</div>

The address operator @ returns the address of an identifier that is associated with an address (usually a variable or routine, but also a label).

Normally, the value @ returns is an untyped pointer. If you are handling pointers a lot, and want to mitigate issues with passing references of wrong type’s target, you have use the directive {$typedAddress on}.

Here is an example to demonstrate what produces with untyped pointers valid and functional code, but semantically outputs an erroneous result:

pascal
program untypedAddressDemo(input, output, stderr);

procedure incrementIntByRef(const ref: PByte);
begin
    inc(ref^);
end;

var
    foo: integer;
begin
    foo := -1;
    incrementIntByRef(@foo);
    writeLn(foo);
end.

It was intended that 0 (zero) gets printed, but the program prints -256 instead. With {$typedAddress on} compilation fails with an incompatible type error. You usually want the latter behavior (compile-time error) instead of wasting time with hours of debugging.

other remarks

read more


From the Free Pascal wiki, page "@", as it stood on 2024-02-28 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.