RAD Studio Athens

E2033

Go Up to Error and Warning Messages (Delphi)

For a variable parameter, the actual argument must be of the exact type of the formal parameter.


program Produce;

procedure SwapBytes(var B1, B2 Byte);
var
  Temp: Byte;
begin
  Tempย := B1; B1ย := B2; B2ย := Temp;
end;

var
  C1, C2 0..255;     (*Similar to a byte, but NOT identical*)
begin
  SwapBytes(C1,C2);   (*<-- Error message here*)
end.

Arguments C1 and C2 are not acceptable to SwapBytes, although they have the exact memory representation and range that a Byte has.


program Solve;

procedure SwapBytes(var B1, B2 Byte);
var
  Temp: Byte;
begin
  Tempย := B1; B1ย := B2; B2ย := Temp;
end;

var
  C1, C2 Byte;
begin
  SwapBytes(C1,C2);   (*<-- No error message here*)
end.

So you actually have to declare C1 and C2 as Bytes to make this example compile.