[Issue 11379] Cannot combine calling convention with an existing alias

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 29 11:17:05 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11379



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-10-29 11:17:04 PDT ---
A use-case could be to apply a linkage from a source function type to a target
function type, for example:

-----
import std.string;
import std.traits;

template ApplyLinkage(Source, Target)
{
    enum link = functionLinkage!Source;

    mixin(q{
       alias extern(%s) %s ApplyLinkage;
    }.format(link, Target.stringof));
}

extern(C) void foo() { }

void main()
{
    alias Bar = int function(int);
    Bar bar;

    alias C_bar = ApplyLinkage!(typeof(foo), Bar);
    C_bar cBar;

    Bar func;
    func = bar;   // ok, succeeds
    func = cBar;  // ok, fails
}
-----

Currently the .stringof trick is necessary due to this bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list