How to call a method of class D from function of C++ in DLL?

MGW via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 26 21:44:10 PDT 2016


Method which I use now:

source D:
---------
extern (C) {
     int on_metFromD(CEditWin* uk, int aa, int bb) {
         return (*uk).metFromD(int aa, int bb);
     }
}

class CEditWin {
     . . .
     // Method for to call
     int metFromD(int a, int b) {
         return a + b;
     }
}

main() {
     CEditWin f = new CEditWin(); void* pf = &f;
     // save pf and &on_metFromD in DLL
     toTransferInDLL(pf, &on_metFromD);
}

source C++ DLL
--------------
extern "C" typedef int (*execDmet1)(void*, int, int);

extern "C" void toTransferInDLL(void* pf, void* on_metFromD) {
     int rez = ((execDmet1)on_metFromD)(pf, 2, 3);
}

---------------------
How to change a code that it was possible transferring two 
parameters in C++ ( toTransferInDLL(pf, &on_metFromD) ) directly 
to call a method D.

How to call delegate from C++


More information about the Digitalmars-d-learn mailing list