Sign in Join
Wiki copytemporary

Revision 1 of 1, by Kai Burghardt on 6-23-2020. The page as it is now.

$H

Back to local compiler directives.

The $H or $LONGSTRINGS local compiler directives have the same meaning and determine whether the compiler interprets the reserved word String as an AnsiString.

The $LONGSTRINGS directive uses the ON and OFF switches.

The $H directive uses the + and - switches.

The default is {$H-}. The reserved word String is a ShortString.

The compiler mode {$MODE DELPHI} implies a {$H+} statement, all other modes switch it off. As a result, you should always put {$H+} after a mode directive.

Example:

pascal
 // String is an AnsiString
 {$H+}
 
 // String is an AnsiString
 {$LONGSTRINGS ON}

 // Default; String is a ShortString
 {$H-}

 // Default; String is a ShortString
 {$LongStrings OFF}

The {$H} or {$LONGSTRINGS} directive corresponds to the -Sh command line option.


From the Free Pascal wiki, page "$H", as it stood on 2020-06-23 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.