I am struggling with delegates when retrieving them as function pointers from external functions.
E.g, if I call a declared function that returns a function pointer, I cannot declare it like this as this produces a syntax error:
declare function returnsFuncPtr lib "somelib" () as MyDelegate
Only this works:
declare function returnsFuncPtr lib "somelib" () as Ptr
But then I cannot seem to convert this into a delegate so that I could invoke it.
I understand that delegates need to be objects containing an object reference when they’re pointing to instance methods of objects. But when I’m using global functions as delegates, like in this case, a simple pointer should suffice, right?
Is there any way to solve this other than having to use a stub library that takes the function ptr as a Ptr and then invokes the function accordingly?