[Issue 18385] [REG nightly] function cannot be overloaded with another extern(C) function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 23 10:38:45 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18385
--- Comment #3 from Martin Nowak <code at dawg.eu> ---
(In reply to Jacob Carlborg from comment #0)
> Note that global C function will not have a mangling, but methods of a
> struct or class declared as `extern (C)` will get mangled as a D method.
> This can be used as a callback function for a C function.
So you're bug report is about
cat > bug.d << CODE
struct S
{
extern(C) static void foo(int) {}
extern(C) static void foo(double) {}
}
CODE
dmd -c bug.d
----
Error: function bug.S.foo(double) cannot be overloaded with another extern(C)
function at /home/dawg/Code/D/bug.d(3)
----
instead
?
For top-level functions there is no way to just use C calling convention
without the mangling, so the example from the OP will clearly lead to a
multiple definition problem and undefined behavior dependening on various
linker behaviors.
Introduced here https://github.com/dlang/dmd/pull/7577.
BTW, please use [Reg <upcoming version>] instead of a non-permanent [Reg
nightly]. For nightlies it's the next major version, so 2.079.0 in your case.
--
More information about the Digitalmars-d-bugs
mailing list