www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - mixin template, extern(C/Windows) and mangled name

reply Domain <dont_email empty.com> writes:
I known there is a bug with extern(C) in mixin template: 
https://issues.dlang.org/show_bug.cgi?id=12575

And I can see SimpleDllMain in core.sys.windows.dll, the mangled 
name is correct: DllMain
But my mixin template has wrong mangled name:

mixin template GetMetaData()
{
     extern(Windows) MetaData GetMetaData()
     {
         return MetaData();
     }
}

mixin GetMetaData;

I can see the mangled name is:
_D3app8__mixin911GetMetaDataWZS4zero7plugins8metadata8MetaData
Jul 31
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 1 August 2017 at 03:08:30 UTC, Domain wrote:
 And I can see SimpleDllMain in core.sys.windows.dll, the 
 mangled name is correct: DllMain
main, DllMain, and WinMain are special cased... for yours, I think you'll have to hack it with pragma(mangle) mixin template GetMetaData() { pragma(mangle, "GetMetaData") // or whatever maybe 0 ? extern(Windows) MetaData GetMetaData() { return MetaData(); } } mixin GetMetaData; I think.
Jul 31
parent Domain <dont_email empty.com> writes:
On Tuesday, 1 August 2017 at 03:30:08 UTC, Adam D. Ruppe wrote:
 On Tuesday, 1 August 2017 at 03:08:30 UTC, Domain wrote:
 And I can see SimpleDllMain in core.sys.windows.dll, the 
 mangled name is correct: DllMain
main, DllMain, and WinMain are special cased... for yours, I think you'll have to hack it with pragma(mangle) mixin template GetMetaData() { pragma(mangle, "GetMetaData") // or whatever maybe 0 ? extern(Windows) MetaData GetMetaData() { return MetaData(); } } mixin GetMetaData; I think.
Thanks. Anyone known any plan for issue 12575? It has been 3 years, it looks like not that hard to fix.
Jul 31