Delphi – E2036 Variable required

When you attempt to take the address of an expression or a constant in your delphi program, you will receive this error message.

program Produce;
var
  I: Integer;
  PI: ^Integer;
begin
  PI := Addr(1);
end.

Because a constant, such as 1, does not have a memory address, you cannot use the operator or the Addr standard function on it.

How to fix it?

program Solve;
var
  I: Integer;
  PI: ^Integer;
begin
  PI := Addr(I);
end.
%d bloggers like this: