E2251 Ambiguous overloaded call 'CompareText'

delphi package - madRes, madTools, madStrings, ...
Post Reply
JanDoggen
Posts: 30
Joined: Thu Nov 26, 2009 11:23 am
Location: Netherlands

E2251 Ambiguous overloaded call 'CompareText'

Post 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
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post 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.
Post Reply