RAD Studio (Common)
ContentsIndex
PreviousUpNext
Long strings (Delphi)
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 component library string-type properties. 

The {$H-} state is mostly useful for using code from versions of Delphi 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.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!