RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2010: Incompatible types: '%s' and '%s' (Delphi)

This error message results when the compiler expected two types to be compatible (or similar), but they turned out to be different.

program Produce;

procedure Proc(I: Integer);
begin
end;

begin
  Proc( 22 / 7 ); (*Result of / operator is Real*)
end.

Here a C++ programmer thought the division operator / would give him an integral result - not the case in Delphi.

program Solve;

procedure Proc(I: Integer);
begin
end;

begin
  Proc( 22 div 7 ); (*The div operator gives result type Integer*)
end.

The solution in this case is to use the integral division operator div - in general, you have to look at your program very careful to decide how to resolve type incompatibilities.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!