Working with RTTI
Go Up to Programming with Delphi Index
Introduction
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.
- For information about RTTI for C++, see Run-Time Type Identification (RTTI) Index.
- For information about Delphi RTTI in C++ applications, see Delphi RTTI and C++Builder.
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) |
{$METHODINFO} | N/A |
{$RTTI} | #pragma explicit_rtti |
{$WEAKLINKRTTI} | N/A |
Topics
- Obtaining the RTTI Context
- Querying for Type Information
- General Type Information
- Information for Simple Types
- Information for Structured Types
- Run-Time Operations on Types
- Delphi RTTI and C++Builder
See Also
Code Examples
- Category:RTTI
- RTL.AttributesAndRTTI Sample (a number of code examples use RTTI)