Is it possible to dynamically load a @safe function from a shared library ?

wjoe invalid at example.com
Fri Mar 13 18:11:01 UTC 2020


On Friday, 13 March 2020 at 17:05:32 UTC, Mike Parker wrote:
> On Friday, 13 March 2020 at 16:11:53 UTC, wjoe wrote:
>> On Friday, 13 March 2020 at 16:04:06 UTC, Mike Parker wrote:
>>> On Friday, 13 March 2020 at 15:16:06 UTC, wjoe wrote:
>>>
>>>>    bindSymbol(&apiVersion, "VersionOfAPI");
>>>> }
>>>>
>>>
>>>>
>>>> Is it possible to convince the compiler to look the other 
>>>> way while binding @safe functions from the plugin ?
>>>
>>> It probably has nothing to do with @safe, but is because of 
>>> the void**.
>>>
>>> bindSymbol(cast(void**)&apiVersion, "VersionOfAPI");
>>
>> Than works, thanks :)
>> But isn't apiVersion a function pointer ?
>
> Yes, but when you take the address of *any* kind of pointer, 
> you can't assign it to void** without a cast.

Didn't know that. I'm curious as to why this is the case.
This also means that LoadPlugin() can't be @safe - or at least 
the call to bindSymbol.

Thanks for the reply.



More information about the Digitalmars-d-learn mailing list