<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jul 5, 2015 at 2:41 PM, Ewald <span dir="ltr"><<a href="mailto:ewald@yellowcouch.org" target="_blank">ewald@yellowcouch.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><div>On 30 Jun 2015, at 20:54, silvioprog wrote:</div><br><blockquote type="cite"><div dir="ltr"><div><br></div><div>The code above compiles fine in Delphi (tested in XE 7), but in FPC I got the following compiling error:</div><div><br></div><div>Unit1.pas(46,14) Error: Incompatible types: got "<class method type of procedure({Open} Array Of Byte;out AnsiString) of object;Register>" expected "<procedure variable type of procedure({Open} Array Of Byte;out AnsiString);Register>".</div><div><br></div><div>Is this a bug or I need to enable some switch?</div><div><br></div></div></blockquote><div><br></div></span><div>Back in 2012 I had a similar issue. Original message can be found here: <a href="http://lists.freepascal.org/pipermail/fpc-pascal/2012-December/035921.html" target="_blank">http://lists.freepascal.org/pipermail/fpc-pascal/2012-December/035921.html</a></div></div><div><br></div><div>I fixed it by declaring a type that includes the hidden parameter mentioned in that thread, so in your case:</div><div><br></div><div> Type</div><div><span style="white-space:pre-wrap"> </span>TMyProc = procedure(aClassType: TClass; ABytes: array of Byte; out AOutput: AnsiString);</div><div><br></div><div>the invocation then becomes</div><div><span style="white-space:pre-wrap"> </span>FMyProc(ClassType, [65, 66, 67], S);</div><div><br></div><div>instead of </div><div><span style="white-space:pre-wrap"> </span>FMyProc([65, 66, 67], S);</div><div><br></div><div>And, of course, the assignment to FMyProc becomes more verbose and less type-safe: </div><div><span style="white-space:pre-wrap"> </span>FMyProc := TMyProc(Pointer(@DoMyProc));</div><div><br></div><div>NOTE: This is a hack. It is not documented anywhere, but i have used this approach since late 2012 without any problems so far. Better be careful and write a small sanity test that checks correct operation every time you use a new compiler.</div></div></blockquote></div><div><br></div><div>Very nice, I'll try that, thank you! =)</div><div><br></div>-- <br><div class="gmail_signature">Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div>