[fpc-pascal] overloading function
LacaK
lacak at zoznam.sk
Fri May 2 07:45:06 CEST 2014
Hi,
I am trying understand how FPC determines which version of overloaded
function to call.
Take as example these 2 functions (from SysUtils):
1. function StrPLCopy(Dest: PChar; Source: string; MaxLen: SizeUInt):
PChar; overload;
2. function StrPLCopy(Dest: PWideChar; const Source: UnicodeString;
MaxLen: SizeInt): PWideChar; overload;
And in program I use:
var p: pointer;
s: string;
begin
StrPLCopy(p, s, 10);
end;
It seems, that 2nd "unicode" version of StrPLCopy is called. But why?
I am thinking as:
1st parameter is untyped pointer, so no one of function can be prefered
2nd parameter is "string" which exactly match 1st function signature
3rd parameter is "integer constant" which mach both signatures
So it seems to me, that 1st version of function signature matches
better, because of exact match of 2nd parameter ... why is then called
2nd version?
-Laco.
More information about the fpc-pascal
mailing list