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

Delphi Compiler Error

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

Reason for the Error & Solution

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

In general, you have to look at your program very carefully to decide how to resolve type incompatibilities.

If you receive the following error message:

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

The first type in this message (Integer) is the type expected, and the second type (Extended) is the type that was given. An Extended type cannot be accommodated as an Integer.

Here is another example:

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

The programmer thought the division operator /, which is used in C++, would yield an integral result — but this is not the case in Delphi.

The solution in this case 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.

Other examples include:

  • with pointer incompatible with ^Integer
  • Generics: Object<T1> incompatible with TObject<T2>

See Also

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...