[Lazarus] LongString does not work?
Jürgen Hestermann
juergen.hestermann at gmx.de
Sun Mar 3 14:11:12 CET 2013
Am 2013-03-03 13:49, schrieb Xiangrong Fang:
> Hi Sven,
> {$mode objfpc}{$H+}
> TConfiguration = packed record
> DataFolder: string;
> end;
> does not work, but:
A (Ansi)string in {$H+} mode is just a pointer (to the characters of the string). So sizeof(DataFolder)=4 (or 8) in all cases. There is no room for the string unless you configure it with SetLength(DataFolder,MaxPathLen). But even then the record does not store the characters. It only stores the pointer to the string:
DataFolder = pointer
DataFolder[1] = DataFolder^[1] = first character of the string.
There is an automatic dereferenciation that allows to write DataFolder[x] although the logic would require DataFolder^[1].
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130303/ea16d1fa/attachment-0003.html>
More information about the Lazarus
mailing list