[fpc-pascal] FPC can't determine overloaded function to call

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Thu Apr 28 15:02:38 CEST 2016


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

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp



More information about the fpc-pascal mailing list