On Wed, 16 Nov 2011, Rainer Stratmann wrote:
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 ] ?
Because the definition of the type 'ShortString':
ShortString = String[255];
is somewhere in the ObjPas or system unit.
If the compiler finds a size after the 'String' keyword, it automatically
assumes a "shortstring" (by this I mean the compiler internal's idea of
"shortstring").
The definition of 'Shortstring' as shown above is just an aid, for Delphi
compatibility.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal