Page 1 of 1

E2251 Ambiguous overloaded call 'CompareText'

Posted: Tue Feb 09, 2010 12:59 pm
by JanDoggen
Hi, my Delphi 2007 refuses to compile because of this error.
My code:
with List do
begin
for i := 0 to Items.Count-1 do
begin
if CompareText(Items.Caption, SomeStr) = 0 then
so there's not much I can do there.

The help says:
Based on the current overload list for the specified function, and the programmed invocation, the compiler is unable to determine which version of the procedure should be invoked.

program Produce;

procedure f0(a : integer); overload;
begin
end;

procedure f0(a : integer; b : char = 'A'); overload;
begin
end;

begin
f0(1);
end.
In this example, the default parameter that exists in one of the versions of f0 makes it impossible for the compiler to determine which procedure should actually be called.

Is this what is going on in madStrings and can it be fixed?

Bye
Jan

Posted: Wed Feb 10, 2010 10:51 pm
by madshi
What type does SomeStr have? Just "string"? In that case simply use "madStrings.CompareText" instead of "CompareText". I think that should fix the problem.