E2010 Incompatible types - '%s' and '%s' (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

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:

See Also