Call delegate from C++
    Nicholas Wilson 
    iamthewilsonator at hotmail.com
       
    Wed Apr 24 16:20:17 UTC 2019
    
    
  
How do you pass a delegate to a c++ function to be called by it?
The function to pass the delegate to is:
extern (C++) int
fakeEntrypoint(
     extern(C++) void function(void* /*delegate's context*/) func,
     void* /*delegate's context*/ arg);
What I want is:
int entrypoint(scope void delegate() func)
{
     return fakeEntrypoint(
                 // for some reason func.funcptr is void function()
                 cast(void function(void*))func.funcptr,
                 func.ptr);
}
but that fails with
cannot pass argument cast(void function(void*))func.funcptr of 
type
void function(void*) to parameter extern (C++) void 
function(void*) func
    
    
More information about the Digitalmars-d-learn
mailing list