Type Switch
Syntax {$M+} or {$M-}
{$TYPEINFO ON} or {$TYPEINFO OFF}
Default {$M-}
{$TYPEINFO OFF}
Scope Local
The $M switch directive controls
generation of runtime 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 runtime type information for fields, methods, and
properties 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.
Note: The TPersistent class defined in the Classes unit of the VCL and CLX
is declared in the {$M+} state, so any class derived from TPersistent will have
RTTI generated for its published sections. The VCL/CLX uses the runtime type
information generated for published sections to access the values of a
component's properties when saving or loading form files. Furthermore, the IDE
uses a component's runtime type information to determine the list of properties
to show in the Object Inspector.
There is seldom, if ever, any need for an application to directly use the $M compiler switch.