[fpc-pascal] Re: pchar with more than 255 characters

Rainer Stratmann RainerStratmann at t-online.de
Wed Nov 16 16:55:23 CET 2011


Am Monday 14 November 2011 22:00:28 schrieb Jonas Maebe:
> On 13 Nov 2011, at 14:02, Rainer Stratmann wrote:
> > Am Sunday 13 November 2011 02:15:07 schrieb leledumbo:
> >> It works when {$LONGSTRINGS ON} or {$H+} directive exists. I think the
> >> compiler treats functions receiving array of char (or pointer to it) as
> >> ShortString when none of the directives above exist.
> >
> > No it does not work then.
> > I put already the -Sh- additional compiler arg.
>
> -Sh- Is the same as {$h-} or {$longstrings off}. You need -Sh (provided
> that there's no {$mode fpc/objfpc/tp/macpas} in the source file, since that
> will disable them again).

With {$h+} it works.

But when having pchar I wonder why it generally is not possible to make 
strings longer than 255 as it was possible in the previous compiler version.

For shortsting I accept strings not longer than 255 chars.

Why is it not possible to make a var like
svar : shortstring[ 20 ] ?

The whole program I made is compiled with {$h-} so it would be much 
fault-prone work to put everywhere {$h+} and then {$h-} again.



More information about the fpc-pascal mailing list