#pragma explicit_rtti

From RAD Studio
Jump to: navigation, search

Go Up to Pragma Directives Overview Index


Syntax (See Pseudo-grammar)

#pragma explicit_rtti [VISIBILITY-CLAUSE]
VISIBILITY-CLAUSE := methods | properties | fields (VISIBILITY-EXPR)
VISIBILITY-EXPR := [__published], [public], [protected], [private]

Description

Use #pragma explicit_rtti to control the amount of RTTI that is generated for Delphi-style classes and records. You can state explicitly the kind of members (methods, fields, and so on) with specific visibility (public, protected, and so on) that should have RTTI.

A #pragma explicit_rtti specification applies to each subsequently encountered class member declaration for the remainder of the file, or until another #pragma explicit_rtti specification changes the settings.

The member kinds (methods, fields and properties) can be in any order. The argument for each member kind specification must be a comma-separated list of any combination of:

  • __published
  • public
  • protected
  • private

If the list is empty, as in:

#pragma explicit_rtti methods()

then none of the members of that kind is exposed. When a member kind is not specified (as properties and fields are not in the example above), then the current setting is preserved.

Default Setting

The default setting is:

#pragma explicit_rtti methods (__published, public) properties (__published, public) fields(__published, public, protected, private)

The following table illustrates this setting:

Member visibility
Member kind
__published public protected private
Methods + +    
Properties + +    
Fields + + + +

It is possible to define the member list as a preprocessor macro, as in the following example:

#define VIS_ANY __published, public, protected, private
#define VIS_NONE
#pragma explicit_rtti methods(VIS_ANY) properties(VIS_NONE)

Using #pragma explicit_rtti with LiveBindings

LiveBindings uses RTTI (run-time type information), which is generated by the Delphi compiler for classes and types that are written in Delphi. A C++ application does not need to use the #pragma explicit_rtti if it uses only classes and types written in Delphi. This includes all the standard VCL or FMX classes such as TForm, TButton, TMemo, and so on. These VCL or FMX classes and types were written in Delphi, and already have RTTI that the Delphi compiler generated.

  • If you want to use LiveBindings in C++ applications using Delphi-like classes or types that you have written in C++, you must use the #pragma explicit_rtti methods() directive.
  • If you want to use LiveBindings in C++ applications that have classes or types that were written in Delphi (such as VCL or FMX classes and types), you should not use the #pragma explicit_rtti methods() directive.

See Also