OBJTYPENAME directive (Delphi)
Go Up to Delphi Compiler Directives (List) Index
Type |
Parameter |
Syntax |
{$OBJTYPENAME typeIdent ['{B|N}typeNameInObj']} |
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.