I'm currently updating some existing Delphi code to compile on MacOS using Delphi XE2.
The Delphi XE2 Update 3 is installed.
On Win32 and Win64 a particular bit of the code works as expected and it also compiles/runs as expected when compiling with Delphi 4 all the way up to Delphi XE.
However, when compiling for MacOS the same piece of code doesn't work the same way. We've also had some crashes on the Mac - but that might have been the XE2 debugger.
type
TFixedSizeAnsiStringArray = array[0..255] of AnsiString;
procedure TForm1.Button1Click(Sender: TObject);
var
FirstArray: TFixedSizeAnsiStringArray;
SecondArray: TFixedSizeAnsiStringArray;
begin
FirstArray[0] := 'Apple';
FirstArray[1] := 'Banana';
FirstArray[2] := 'Pineapple';
// ...
SecondArray := FirstArray;
Memo1.Lines.Add(SecondArray[0]);
Memo1.Lines.Add(SecondArray[1]);
// ....
end;
On Windows, all the elements of SecondArray are the same as the elements of FirstArray.
But on MacOS (when it does run) only the first element of SecondArray has the correct value.
It's easy to fix with a for
loop - but understanding why it's different between Windows and MacOS would be good to know.
Maybe something to do with the use of AnsiString?