Procedural types and overloaded functions lazarus / 8-Other ---------------------------------------------------------------------- sasa · 2006-03-14 00:31 During porting several Delphi units and demos, I found a difficultie using procedural types with Lazarus (perhaps core of the problem lies in FreePascal). type   EncodingStringProc = function ( const s: string; MIMELine: integer = 0): string;   DecodingStringProc = function ( const s: string): string; ... function DoEncodingString(   const note: string;   Encoding: EncodingStringProc;   Decoding: DecodingStringProc;   const Data:string; MIMELine: integer = 0): integer; ... DoEncodingString('SZCodeOnlyBase64 Ver 1.2     = ',     SZFullEncodeOnlyBase64,     SZDecodeBase64,     All_chr); Error is located on upper line: "Wrong number of parameters specified" As it is required, all overloaded functions from unit are exported; However, this is legal syntax for Delphi 7. Perhaps some compiler directive are necessary to be expllicitly set, except -Sd. Otherwise, this can be a bug. The above code is cut from SpeedTest project for SZCodeBaseX unit. Unit for Delphi can be found on my site. Thanks in advance. Sasa ---------------------------------------------------------------------- Marc · 2006-03-14 10:37 in objfpc mode, when passing procedures, you need to place an @ in front of them (you pass the adress of the proc) so the call will beCode: [Select]DoEncodingString('SZCodeOnlyBase64 Ver 1.2 = ', @SZFullEncodeOnlyBase64, @SZDecodeBase64, All_chr); ---------------------------------------------------------------------- sasa · 2006-03-14 13:34 Thank you for your kind answer. Actually, in this specific example it is a quite sensitive issue. Here should be passed one of the overloaded functions and since compiler doesn't know it in the moment of compiling, it can be passes that way. At least compiler refuses to pass overloaded functions. Sasa ---------------------------------------------------------------------- Marc · 2006-03-17 15:48 you mean that you have several (overloaded) versions of SZFullEncodeOnlyBase64 (or SZDecodeBase64)? ---------------------------------------------------------------------- sasa · 2006-03-17 16:17 That is correct. There is several SZDecodeBase64 overloaded functions - a reason why can't be passed as a simple pointer. I hope there is another way in Lazarus which can allow this specific need. Sasa ---------------------------------------------------------------------- Marc · 2006-03-20 10:10 Define one proc with the args you need for SZDecodeBase64 and call the overloaded proc in there ---------------------------------------------------------------------- sasa · 2006-03-21 10:46 It is confimed bug in FPC (please see #4920 to #4922) and fixes are probably released in the latest SVN revision. For FPC bug tracker I've created simple console project to demonstrate the problem. It can be downloaded from: www.szutils.net/files/FPOverloadDemo.zip