Bug 11379 – Cannot combine calling convention with an existing alias

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-29T11:14:00Z
Last change time
2013-11-21T03:33:17Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-10-29T11:14:59Z
I think this may be a dupe but I can't find the report: ----- void main() { alias Foo = int function(int); // workaround mixin("alias extern(C) " ~ Foo.stringof ~ " C_Foo;"); // ok static assert(!is(C_Foo == Foo)); // non-mixin version alias extern(C) Foo C_Foo2; // fails static assert(!is(Foo == C_Foo2)); } -----
Comment #1 by andrej.mitrovich — 2013-10-29T11:17:04Z
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.
Comment #2 by yebblies — 2013-11-21T03:33:17Z
*** This issue has been marked as a duplicate of issue 10470 ***