E2250 There is no overloaded version of '%s' that can be called with these arguments Delphi error
While migrating our legacy project from Delphi 7 to Delphi XE5, we encountered "E2250 There is no overloaded version of '%s' that can be called with these arguments" error many times. The codes were written in Delphi 7 which were working fine but raised the error when compiled in Delphi XE5 or later. We faced the error on statements where we have called functions like Pos, StrPas, StrCopy, Offset , StrToInt64 etc. So here for help to others, I will explain why we get this error and how to solve it.
Some errors we faced frequently.
E2250 There is no overloaded version of 'Offset' that can be called with these arguments
E2250 There is no overloaded version of 'StrCopy' that can be called with these arguments
E2250 There is no overloaded version of 'StrToInt64' that can be called with these arguments
Why we get this error ?
This error occurs when we attempt to call a overloaded function with invalid arguments or cannot be resolved as per function versions. Invalid arguments means may be different type or in different position of passed parameters.
For example.
procedure proc1 (a : integer); overload;
begin
…….
end;
procedure proc1 (a : char); overload;
begin
………
end;
//calling of function//
begin
proc1 (1.2);
end.
The overloaded procedure proc1 has two versions: one which takes a char and one which takes an integer. However, the call to proc1 uses a floating point type, which the compiler cannot resolve into neither a char nor an integer so it will result “There is no overloaded version of '%s' that can be called with these arguments” Delphi error.
How to solve it ?
To solve such kind of error we need to pass valid arguments to match to the overloaded function call. So here we can solve the issue with calling.
Solution
begin
proc1 (1);
end.
However in some function calls like StrPas, Strcopy, Offset to solve the error we need to changed the type of variable or we need to do typecast of variable.
Comments
Post a Comment