Re: How do I pass a call back Class and its method to an external library *.so file writting in C++
Dennis via fpc-pascal <[email protected]>
| Newsgroups | gmane.comp.compilers.free-pascal.general |
|---|---|
| Message-ID | <[email protected]> |
>
>
> 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
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal