Compiler Attributes

From RAD Studio
Jump to: navigation, search

Go Up to Attributes (RTTI)


Some special attributes trigger certain features of Delphi compilers.

Ref

The Ref attribute is used to qualify constant function parameters so that they are passed by reference (not by value) to the function. For more information, see Constant Parameters.

Unsafe

Tag the Result of a function as Unsafe to make the compiler treat the function result as “unsafe”, which disables ARC management of the object. For more information, see The Unsafe Attribute.

Volatile

The volatile attribute is used to mark fields that are subject to change by different threads, so that code generation does not optimize copying the value in a register or another temporary memory location.

You can use the volatile attribute to mark the following declarations:

You cannot use the volatile attribute to mark the following declarations:

type
    TMyClass = class
    private
        [volatile] FMyVariable: TMyType;
    end;

Weak

The weak attribute is used to mark a declaration as a weak reference. For more information, see Weak References.

See Also