Run-Time Type Information (Delphi)
Go Up to Delphi Compiler Directives (List) Index
Type |
Switch |
Syntax |
{$M+} or {$M-} {$TYPEINFO ON} or {$TYPEINFO OFF} |
Default |
{$M-} {$TYPEINFO OFF} |
Scope |
Local |
The {$M} switch directive controls generation of run-time type information (RTTI). When a class is declared in the {$M+} state, or is derived from a class that was declared in the {$M+} state, the compiler generates run-time type information for properties and events that are declared in a published section. If a class is declared in the {$M+} state, and is not derived from a class that was declared in the {$M} state, published sections are not allowed in the class. Note that if a class is forward declared, the first declaration of the class must be declared with the $M switch.
When the $M switch is used to declare an interface, the compiler generates run-time type information for all properties. That is, for interfaces, all members are treated as if they were published.
There is seldom, if ever, any need for an application to directly use the {$M}compiler switch.