E2175
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
E2175 means you tried to use runtime type information (RTTI) on a type that does not have it generated. RTTI allows code to inspect types at runtime — but it must be enabled for the specific type using the {$TYPEINFO ON} directive. Fix it by enabling the TYPEINFO compiler directive before the type declaration.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- Calling TypeInfo() on a type that was compiled without TYPEINFO enabled
- Using the Rtti unit to inspect a record or enumeration that has no type information
- Registering a type for streaming without enabling type information for it
- Using published properties in a class that does not have TYPEINFO ON
- Attempting to use a type in a generic RTTI-based framework without the necessary directive
How to Fix It
-
Add {$TYPEINFO ON} immediately before the type declaration that needs RTTI, and {$TYPEINFO OFF} after it to restore the default.
Example: {$TYPEINFO ON} type TMyRecord = record ... end; {$TYPEINFO OFF}
-
For classes, use the 'published' section — properties and methods in a published section automatically have type information generated.
Classes descended from TPersistent or TComponent generate RTTI for published members automatically without requiring {$TYPEINFO ON}.
-
In modern Delphi (XE and later), use the expanded RTTI with {$RTTI EXPLICIT ...} directives to control RTTI generation more precisely.
Example: {$RTTI EXPLICIT METHODS([vcPublished]) PROPERTIES([vcPublished])} gives fine-grained control over what RTTI is generated.
-
Check whether TypeInfo() is really necessary — if you are just registering a class with a streaming framework, ensure you use the correct registration method.
For DFM streaming, inherit from TPersistent and declare properties as published — no manual TypeInfo() call is needed.
-
If the type is from a third-party library and has no RTTI, you may need to wrap it in your own class that does have RTTI.
You cannot retroactively add RTTI to a type whose source you cannot modify — the TYPEINFO directive must be applied when the type is compiled.
When to Call a Professional
This is a compiler error — no professional repair needed. Fix it by reading the error message and correcting the code. The Delphi IDE highlights the exact line causing the problem.
Frequently Asked Questions
What is RTTI and why would I need it?
RTTI stands for Runtime Type Information — it is data the compiler embeds in the executable that describes types at runtime. RTTI lets you do things like get the name of a type, iterate its properties, call methods by name, and serialize/deserialize objects. Delphi uses RTTI internally for the Object Inspector, DFM streaming, and many third-party frameworks like JSON serializers.
Does enabling TYPEINFO affect performance or executable size?
Yes — RTTI data adds to the executable size because the type descriptions are compiled into the binary. For small records or types, the overhead is minimal. For large class hierarchies with many properties, it can be significant. That is why TYPEINFO is off by default for non-class types — you opt in only where needed.
What is the difference between old-style RTTI and the new extended RTTI in Delphi XE+?
Old-style RTTI (TypeInfo()) only provides information about published properties and the type name — it is limited. Extended RTTI (the Rtti unit, TRttiContext) provides full access to all visibility levels, methods, fields, attributes, and generic type information. For new code that needs RTTI, always use the extended Rtti unit — it is much more powerful and flexible.