digitalmars.D.learn - C++ calling convention only
- Benjamin Thaut (4/4) Feb 19 2015 Is it possible to declare a function in D which gets the C++ calling
- John Colvin (3/7) Feb 19 2015 You can use pragma(mangle, ...) to set whatever mangling you like.
- John Colvin (4/13) Feb 19 2015 I would duplicate the declaration, once without extern(C++), once
- Benjamin Thaut (2/5) Feb 20 2015 Yes that would work. But using pragma(mangle) feels so hacky...
- John Colvin (5/12) Feb 20 2015 I agree. Wrap it in a mixin / mixin template?
- Benjamin Thaut (9/14) Feb 20 2015 Well the use case is creating a function which sole purpose it is
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (3/19) Feb 21 2015 For C++, you can just use the newly added namespace support:
- Benjamin Thaut (3/5) Feb 21 2015 Thats actually a good idea. Thanks.
Is it possible to declare a function in D which gets the C++ calling convetion but not the C++ mangling? Kind Regards Benjamin Thaut
Feb 19 2015
On Thursday, 19 February 2015 at 18:25:10 UTC, Benjamin Thaut wrote:Is it possible to declare a function in D which gets the C++ calling convetion but not the C++ mangling? Kind Regards Benjamin ThautYou can use pragma(mangle, ...) to set whatever mangling you like.
Feb 19 2015
On Thursday, 19 February 2015 at 21:33:50 UTC, John Colvin wrote:On Thursday, 19 February 2015 at 18:25:10 UTC, Benjamin Thaut wrote:I would duplicate the declaration, once without extern(C++), once with, the use the .mangleof from the 1st to set the mangle of the 2nd with pragma(mangleIs it possible to declare a function in D which gets the C++ calling convetion but not the C++ mangling? Kind Regards Benjamin ThautYou can use pragma(mangle, ...) to set whatever mangling you like.
Feb 19 2015
On Thursday, 19 February 2015 at 21:34:57 UTC, John Colvin wrote:I would duplicate the declaration, once without extern(C++), once with, the use the .mangleof from the 1st to set the mangle of the 2nd with pragma(mangleYes that would work. But using pragma(mangle) feels so hacky...
Feb 20 2015
On Friday, 20 February 2015 at 12:23:31 UTC, Benjamin Thaut wrote:On Thursday, 19 February 2015 at 21:34:57 UTC, John Colvin wrote:I agree. Wrap it in a mixin / mixin template? Why do you need this? Presumably it'll be hidden in the depths of some library / bindings where beauty is somewhat optional? Using the .mangleof from an extern(D) function should mean it's robust.I would duplicate the declaration, once without extern(C++), once with, the use the .mangleof from the 1st to set the mangle of the 2nd with pragma(mangleYes that would work. But using pragma(mangle) feels so hacky...
Feb 20 2015
On Friday, 20 February 2015 at 13:00:39 UTC, John Colvin wrote:I agree. Wrap it in a mixin / mixin template? Why do you need this? Presumably it'll be hidden in the depths of some library / bindings where beauty is somewhat optional? Using the .mangleof from an extern(D) function should mean it's robust.Well the use case is creating a function which sole purpose it is to create a function pointer from it and pass it to C++. If it recieves C++ mangling however I have to pay attention that it does not conflict with any other C++ symbols. The same goes for extern(C). Sometimes you want to create functions with a C calling convetion so you can create a function pointer from it. With extern(C) its even a bigger problem because the C mangling conflicts a lot easier.
Feb 20 2015
On Friday, 20 February 2015 at 13:40:12 UTC, Benjamin Thaut wrote:On Friday, 20 February 2015 at 13:00:39 UTC, John Colvin wrote:For C++, you can just use the newly added namespace support: extern(C++, nobody.uses.this.name) myFunc() {}I agree. Wrap it in a mixin / mixin template? Why do you need this? Presumably it'll be hidden in the depths of some library / bindings where beauty is somewhat optional? Using the .mangleof from an extern(D) function should mean it's robust.Well the use case is creating a function which sole purpose it is to create a function pointer from it and pass it to C++. If it recieves C++ mangling however I have to pay attention that it does not conflict with any other C++ symbols. The same goes for extern(C). Sometimes you want to create functions with a C calling convetion so you can create a function pointer from it. With extern(C) its even a bigger problem because the C mangling conflicts a lot easier.
Feb 21 2015
Am 21.02.2015 um 11:30 schrieb "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net>":For C++, you can just use the newly added namespace support: extern(C++, nobody.uses.this.name) myFunc() {}Thats actually a good idea. Thanks.
Feb 21 2015