Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

What does {$h+} do?

blackr1234blackr1234 Member Posts: 31
What does {$h+} do?

In some programs (for example the free pascal ones), people tend to use {$h+}after the first line (program ;).

Just want to know how to use it and when should I use it.

Providing links is appreciated.

Thanks.

Comments

  • quikcarlquikcarl Member Posts: 59
    If you go to the FreePascal.org in the programmer's guide, you will find the meaning. I looked it up.
    [u][italic]1.1.23 $H or $LONGSTRINGS : Use AnsiStrings
    If {$LONGSTRINGS ON} is specified, the keyword String (no length specifier) will be treated as AnsiString, and the compiler will treat the corresponding variable as an ansistring, and will generate corresponding code. This switch corresponds to the -Sh command line option.

    By default, the use of ansistrings is off, corresponding to {$H-}. The system unit is compiled without ansistrings, all its functions accept shortstring arguments. The same is true for all RTL units, except the sysutils unit, which is compiled with ansistrings.[/italic][/u]
    This comes straight from the manaul for version 2.4
  • _Atex__Atex_ Member Posts: 163
    : What does {$h+} do?
    :
    : In some programs (for example the free pascal ones), people tend to
    : use {$h+}after the first line (program ;).
    :
    : Just want to know how to use it and when should I use it.
    :

    {$H+} => forces the compiler to use ansi-strings when no length is specified. Ansi-strings are C style null terminated strings (can have any length, not just 255 as Pascal sort strings are) aka. [b]pchar[/b]. Use this compiler directive only if you have lots of subroutine calls which pass down strings as arguments. Because the use of null terminated strings will result in faster subroutine calls (a pointer is passed which is a few bytes vs. a string what could be 256 byte long), so your code will run faster. Another use is when you have to work with strings longer than 255...
Sign In or Register to comment.