C++ calling convention only

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 21 02:30:22 PST 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:
>>
>> 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.

For C++, you can just use the newly added namespace support:

     extern(C++, nobody.uses.this.name) myFunc() {}


More information about the Digitalmars-d-learn mailing list