Name
$TypedAddress Compiler Directive
Syntax
{$T-} // default
{$TypedAddress Off} // default
{$T+}
{$TypedAddress On}Scope
Local
Description
When $TypedAddress
is enabled, the @
operator returns a typed address of a variable or subroutine. The
default is that the @ operator returns a generic
Pointer type. Even when
$TypedAddress is enabled, assignments of a typed
pointer to the Pointer type are still allowed as
are assignments from Pointer to a specific pointer
type.
Tips and Tricks
Enable
$TypedAddressbecause it encourages good programming practices and careful use of pointers. Unsafe pointer assignments can be caught at compiler time.The
Addrfunction always returns an untypedPointer. If you enable$TypedAddress, useAddrwhen you need an untyped pointer and use@when you want a type-safe address.
Example
var
P: PInteger;
Q: ^Double;
I: Integer;
begin
{$TypedAddress On}
P := @I;
Q := @I; // not allowed because types don't match
{$TypedAddress Off}
Q := @I; // allowed, even though types don't matchSee Also
| @ Operator, Addr Function, Pointer Type |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access