E2016 Array type required (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

This error message is given if you either index into an operand that is not an array, or if you pass an argument that is not an array to an open array parameter.


program Produce;
var
  P: ^Integer;
  I: Integer;
begin
  Writeln(P[I]);
end.

We try to apply an index to a pointer to integer - that would be legal in C, but is not in Delphi.


program Solve;
type
  TIntArray = array [0..MaxInt DIV sizeof(Integer)-1] of Integer;
var
  P: ^TIntArray;
  I: Integer;
begin
  Writeln(P^[I]);   (*Actually, P[I] would also be legal*)
end.

In the Delphi language, we must tell the compiler that we intend P to point to an array of integers.