Delphi – E2010 Incompatible types – ‘%s’ and ‘%s’

When the compiler expects two types to be compatible (or similar), but they turn out to be different, this error message appears.

In general, deciding how to overcome type incompatibilities requires a close examination of your software.

If you get an error message like this:

[DCC Error] Project1.dpr(8): E2010 Incompatible types: 'Integer' and 'Extended'

The expected type (Integer) is the first type in this message, while the second type (Extended) is the type that was delivered. As an Integer, an Extended type cannot be accommodated.

Here’s another illustration:

program Produce;
 
 procedure Proc(I: Integer);
 begin
 end;
 
 begin
   Proc( 22 / 7 ); (*Result of / operator is Real*)
 end.

The programmer expected the division operator /, which is used in C++, to produce an integral result, but this is not the case in Delphi.

In this case, the solution is to use the integral division operator div:

 program Solve;
 
 procedure Proc(I: Integer);
 begin
 end;
 
 begin
   Proc( 22 div 7 ); (*The div operator gives result type Integer*)
 end.