Show: Delphi C++
Display Preferences

OBJTYPENAME directive (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Delphi Compiler Directives (List) Index


Type

Parameter

Syntax

{$OBJTYPENAME typeIdent ['{B|N}typeNameInObj']}

Default

{$APPTYPE GUI}

Scope

Global

$OBJTYPENAME has two purposes. You can use $OBJTYPENAME as follows:

  • To define the typename when creating .obj files.
  • As an internal directive, to tell the Delphi compiler how to mangle a type's name. (Since the mangling must match that of the C++ compiler, this option must only be used in a case where Delphi and C++ do not agree on how to mangle a type.)


In the syntax, 'typeNameInObj' must be prefixed with either 'B' or 'N', as follows:

  • {$OBJTYPENAME typeIdent} // Emit typeIdent with namespace if needed
  • {$OBJTYPENAME typeIdent 'Bsss'} // Emit 'sss' without namespace
  • {$OBJTYPENAME typeIdent 'Nsss'} // Emit 'sss' with namespace if needed


The B-prefixed form is used to generate built-in types. For example: 'Bul' emits 'ul' for the built-in unsigned long type.

The N-prefixed form is used to generate symbolic types like class, struct and enum types. For example: 'NTColor' with {$NODEFINE} in System.UITypes.pas will emit '15Graphics@TColor'.

The OBJTYPENAME directive can be used with the {$EXTERNALSYM} and {$NODEFINE} directives.

You cannot use these directives for alias types:

 type
   TMyIntAlias = Integer; {$OBJTYPENAME TMyIntAlias 'Bl'} // error
 type
   TMyIntTyped = type Integer; {$OBJTYPENAME TMyIntTyped 'Bl'} // ok
   TMyIntTyped2 = type TMyIntTyped; // 'Bl' is inherited from base type.

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance