| Thread overview | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 16, 2015 C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
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@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
| ||||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | "Benjamin Thaut" wrote in message news:mbtena$2n46$1@digitalmars.com... > 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. struct X(T) { pragma(msg, X.stringof); } void main() { X!(typeof(*(void function()).init)) x; } | |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | Am 17.02.2015 um 02:21 schrieb Daniel Murphy:
>
> struct X(T) { pragma(msg, X.stringof); }
>
> void main()
> {
> X!(typeof(*(void function()).init)) x;
> }
>
Error: ICE: Unsupported type void()
So close...
| |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | "Benjamin Thaut" wrote in message news:mbuok2$pn5$1@digitalmars.com... > Error: ICE: Unsupported type void() > > So close... Good news is that that's a compiler bug and not a language limitation. Although allowing you to pass a function type to a template in the first place might also be a compiler bug. D/C++ interop really works best when you can massage the C++ side a little. | |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | On 2/16/2015 10:54 PM, Benjamin Thaut wrote:
> Am 17.02.2015 um 02:21 schrieb Daniel Murphy:
>>
>> struct X(T) { pragma(msg, X.stringof); }
>>
>> void main()
>> {
>> X!(typeof(*(void function()).init)) x;
>> }
>>
>
> Error: ICE: Unsupported type void()
>
> So close...
Please file bugzilla!
| |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On 2/16/2015 11:42 PM, Daniel Murphy wrote:
> "Benjamin Thaut" wrote in message news:mbuok2$pn5$1@digitalmars.com...
>
>> Error: ICE: Unsupported type void()
>>
>> So close...
>
> Good news is that that's a compiler bug and not a language limitation. Although
> allowing you to pass a function type to a template in the first place might also
> be a compiler bug.
>
> D/C++ interop really works best when you can massage the C++ side a little.
True, it might be easier to adjust the C++ side so it takes a pointer to a function type.
| |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 17 February 2015 at 08:16:37 UTC, Walter Bright wrote:
>
> True, it might be easier to adjust the C++ side so it takes a pointer to a function type.
In this case it would be really ugly
ezDelegate<void()> vs ezDelegate<void(*)()>
I will do a pull request later today fixing this mangling issue.
| |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Am 17.02.2015 um 09:13 schrieb Walter Bright: > On 2/16/2015 10:54 PM, Benjamin Thaut wrote: >> Am 17.02.2015 um 02:21 schrieb Daniel Murphy: >>> >>> struct X(T) { pragma(msg, X.stringof); } >>> >>> void main() >>> { >>> X!(typeof(*(void function()).init)) x; >>> } >>> >> >> Error: ICE: Unsupported type void() >> >> So close... > > Please file bugzilla! https://issues.dlang.org/show_bug.cgi?id=14195 https://github.com/D-Programming-Language/dmd/pull/4419 | |||
February 17, 2015 Re: C++ function signature template parameter mangling issue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | On 2/17/2015 11:25 AM, Benjamin Thaut wrote:
> Am 17.02.2015 um 09:13 schrieb Walter Bright:
>> Please file bugzilla!
>
> https://issues.dlang.org/show_bug.cgi?id=14195
> https://github.com/D-Programming-Language/dmd/pull/4419
Thank you
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply