Type Switch
Syntax {$H+} or {$H-}
{$LONGSTRINGS ON} or {$LONGSTRINGS OFF}
Default {$H+}
{$LONGSTRINGS ON}
Scope Local
Remarks
The $H directive controls the meaning of the reserved word string when used alone in a type declaration. The generic type string can represent either a long, dynamically-allocated string (the fundamental type AnsiString
) or a short, statically allocated string (the fundamental type ShortString).
By default {$H+}, Delphi defines the generic string type to be the long AnsiString. All components in the component libraries are compiled in this state. If you write components, they should also use long strings, as should any code that receives data from VCL or CLX string-type properties.
The {$H-} state is mostly useful for using code from versions of Object Pascal that used short strings by default. You can locally override the meaning of string-type definitions to ensure generation of short strings. You can also change declarations of short string types to string[255] or ShortString, which are unambiguous and independent of the $H setting
Partager