[fpc-pascal] FPC can't determine overloaded function to call
Peter
peter at pblackman.plus.com
Thu Apr 28 15:22:31 CEST 2016
On 28/04/16 14:02, Graeme Geldenhuys wrote:
> Hi,
>
> I can't figure out why FPC is struggling with figuring out which
> overloaded methods to call. This is my application code which FPC has a
> problem with.
>
> type
> TPDFFloat = Single;
>
> TPDFCoord = record
> X,Y: TPDFFloat;
> end;
>
> var
> W, H: integer
> begin
> ...snip...
> P.DrawImage(25, 190, W div 2, H div 2, IDX); // this fails
>
> Yet this works
> P.DrawImage(25, 190, Integer(W div 2), Integer(H div 2), IDX);
>
>
> Here are the overloaded DrawImage() definitions [sorry if you email
> client wraps this badly]:
>
> { X, Y coordinates are the bottom-left coordinate of the image. AWidth
> and AHeight are in image pixels. }
> Procedure DrawImage(const X, Y: TPDFFloat; const AWidth, AHeight,
> ANumber: integer); overload;
>
> Procedure DrawImage(const APos: TPDFCoord; const AWidth, AHeight,
> ANumber: integer); overload;
>
> { X, Y coordinates are the bottom-left coordinate of the image. AWidth
> and AHeight are in UnitOfMeasure units. }
> Procedure DrawImage(const X, Y: TPDFFloat; const AWidth, AHeight:
> TPDFFloat; ANumber: integer); overload;
>
> Procedure DrawImage(const APos: TPDFCoord; const AWidth, AHeight:
> TPDFFloat; ANumber: integer); overload;
>
>
> This is the compiler error message I got:
> ==============================
> Compile Project, Target: testfppdf: Exit code 1, Errors: 1, Hints: 2
> testfppdf.lpr(281,46) Error: Can't determine which overloaded function
> to call
> fppdf.pp(1802,20) Hint: Found declaration: TPDFPage.DrawImage(const
> Single,const Single,const Single,const Single,const LongInt);
> fppdf.pp(1788,20) Hint: Found declaration: TPDFPage.DrawImage(const
> Single,const Single,const LongInt,const LongInt,const LongInt);
> ==============================
>
>
> Doesn't the code ⸢(W div 2)⸥ resolve to an Integer result? W is an
> Integer type, and DIV is an integer division.
>
> I'm using 64-bit FPC 2.6.4.
>
> Regards,
> Graeme
>
Sizeof 'W' is 2
Sizeof '(W div 2)' is 8
I suspect '(W div 2) gives int64.
Regards,
Pete
More information about the fpc-pascal
mailing list