[Issue 12575] extern(C) mangling ignored inside mixin template
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon Apr 21 12:05:01 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=12575
Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com
--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
Technically they are part of a "namespace", since you can disambiguate them:
-----
mixin template T1()
{
    extern(C) void fizzle() { }
}
mixin template T2()
{
    extern(C) void fizzle() { }
}
mixin T1!() t1;
mixin T2!() t2;
void main()
{
    t1.fizzle();
    t2.fizzle();
}
-----
So I guess that's why they're mangled. As a workaround you can use this:
-----
mixin template T()
{
    // or just pragma(mangle, "fizzle"), but this will at least error if
    // you change the function name
    pragma(mangle, __traits(identifier, fizzle))
    extern(C) void fizzle();
}
mixin T!();
void main()
{
    fizzle();
}
-----
--
    
    
More information about the Digitalmars-d-bugs
mailing list