I want to instantiate a function pointer:
static void GetProc (out function f) {
auto full = demangle(f.mangleof);
auto name = full[full.lastIndexOf('.')+1..$];
f = cast(typeof(f)) GetProcAddress(hModule,name.toStringz);
}
But the compiler won't let me use a function-type variable (out function f). I tried using Object but apparently function is not an Object (how-come??). So, how do I pass a function as ref/out variable (without using template/mixin, which obscures the code and forces me to add many typeof statements...) ?
There is no type called function. A function must specified the return type and argument type like int function(double, string). If you want to support any kind of function, use a template
static void GetProc(T)(out T f) if (isFunctionPointer!T)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With