Working with RTTI

From RAD Studio
Jump to: navigation, search

Go Up to Programming with Delphi Index


Run-time type information (RTTI) is a programming paradigm in which information about a type can be obtained at run time. If RTTI generation is enabled, the resulting binary includes special metadata that contains information about types (for example, class ancestry, declared fields, annotated attributes). Using the functionality provided in the System.Rtti unit, you can obtain this information at run time. The net result is the ability to create more abstract and generalized frameworks that can operate on any type that exposes RTTI.

Note: This section describes RTTI for the Delphi language.

Note: Run-time type information is not generated for generic methods.

Control of RTTI Generation

Use the following compiler directives to control the generation of run-time type information. You may want to restrict the generation of RTTI to reduce the executable size.

Delphi C++
{$M}, {$TYPEINFO} __declspec(delphirtti)
{$RTTI} #pragma explicit_rtti


See Also

Code Examples