[fpc-pascal] Best integer type to be used for string indexes
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Jun 20 00:06:27 CEST 2011
On Sun, 19 Jun 2011 23:57:04 +0200 (CEST)
Michael Van Canneyt <michael at freepascal.org> wrote:
>[...]
> >> Ansistring is not capable of keeping more than High(Integer) bytes.
> >
> > That's not true. At least 3*high(integer) compiles and runs fine here on
> > 64bit:
> >
> > var
> > s: ansistring;
> > begin
> > SetLength(s,3*High(integer));
> > s[length(s)]:='A';
> > s[length(s)]:='B';
> > writeln(s[length(s)],' ',length(s));
> > end.
> >
> > I don't know where the real limit is.
>
> Hm. I checked again.
>
> Indeed, the hidden ansistring record contains
> TAnsiRec = Packed Record
> Ref,
> Len : SizeInt;
> First : Char;
> end;
> Which in fact means that the limit is the OS memory limit.
Now it is no longer hidden. ;)
Mattias
More information about the fpc-pascal
mailing list