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].



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to