[fpc-devel] Parameters must match exactly?

Graeme Geldenhuys graemeg.lists at gmail.com
Fri May 14 16:45:50 CEST 2010


I tried using FPC 2.5.1 today to see how compatible is our application with
it compared to FPC 2.4.1

I got stacks of the following errors.  Why is this change forced in FPC
2.5.1?  TBulkInvoiceRateListForm class is a descendant of TfpgWindowBase so
there should be a problem. I don't understand. :-/

frm_bulkinvoiceratelist.pas(84,77) Error: Call by var for arg no. 2 has to
match exactly: Got "TBulkInvoiceRateListForm" expected "TfpgWindowBase"
fpg_base.pas(2207,31) Hint: Found declaration:
TfpgApplicationBase.CreateForm(TComponentClass,out TfpgWindowBase);
frm_bulkinvoiceratelist.pas(307) Fatal: There were 1 errors compiling
module, stopping

To get my code to compile again, I have to change the following code from

 fpgApplication.CreateForm(TBulkInvoiceRateListForm, BulkDiscountListForm);

...to this...


Now I have to include ugly casts all over the place. :-(

I got similar issues with TStrings and TStringList. TStringList is a
descendant of TStrings, but I can't pass a TStringList type as a parameter
to a method declared with TStrings.

Maybe I don't understand the var parameter correctly (but haven't tested to
see what happens if I remove var from parameter list). If I have a class
instance, when should I pass it to a method or function/procedure as var
and when don't I need to use var parameters?

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

More information about the fpc-devel mailing list