[fpc-pascal] How do I pass a call back Class and its method to an external library *.so file writting in C++
Dennis
dec12 at avidsoft.com.hk
Mon Oct 21 05:09:11 CEST 2024
>
>
> I am expected to create and pass an instance of such class
> ApiProxyWrapperReply in my calling program
> via a function
> void SPAPI_RegisterApiProxyWrapperReply(ApiProxyWrapperReply*
> apiProxyWrapperReply);
>
> and the external library will then call the various methods of
> ApiProxyWrapperReply as 'call-back' functions when needed.
>
>
> Considering that the class only has abstract virtual methods and the
> destructor is non-virtual you *might* be able to do this by declaring
> a raw interface ({$Interfaces Corba}) and declaring all the virtual
> methods in the same order (very important!) with suitable signatures
> and calling convention (for i386 you should pick cppdecl otherwise the
> system default should be alright), implementing that interface in some
> Object Pascal class and then passing an instance of that interface to
> the library.
>
> It could still go wrong due to some differences in the ABI, but it
> might just as well work. 🤷♀️
>
In C++, I was expected to pass the class instance to the external
library. So, In Pascal, do I pass the interface variable to the external
library?
Thanks a lot.
Dennis Poon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20241021/d9f881a3/attachment.htm>
More information about the fpc-pascal
mailing list