C++ function signature template parameter mangling issue

Benjamin Thaut via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 16 10:59:56 PST 2015


I have a c++ struct:

template <typename retval>
struct ezDelegate<retval ()>
{
}

void DelegateTest(ezDelegate<void ()> func) { ... }

And I want to match that on the D side, unfortunately it does not work:

D:
struct ezDelegate(Signature) {}

alias delegate_t = ezDelegate!(void function());

extern(C++) void DelegateTest(delegate func);

D mangles
?DelegateTest@@YAXU?$ezDelegate@$$A6AXXZ@@@Z
void __cdecl DelegateTest(struct ezDelegate<void (__cdecl*)(void)>)

What C++ does:
?DelegateTest@@YAXU?$ezDelegate at P6AXXZ@@@Z
void __cdecl DelegateTest(struct ezDelegate<void __cdecl(void)>)

I understand that "void function()" is actually a function pointer and 
thus the mangling is "correct". But in what way would you actually able 
to mirror the C++ declaration of ezDelegate? Does it even work? This 
would be a central part of my interop with C++ so making it work would 
be nice.

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list