digitalmars.D - overloaded extern(C) called without error
- =?UTF-8?B?Ikx1w61z?= Marques" (9/9) Sep 10 2013 I know that extern(C) functions cannot be legally overloaded, but
- =?UTF-8?B?Ikx1w61z?= Marques" (10/10) Sep 10 2013 I just realized I wasn't clear -- it calls the (wrong) overloaded
- Dicebot (3/13) Sep 10 2013 This is why mixing ABI and mangling in one entity is bad. And why
- Jacob Carlborg (5/7) Sep 11 2013 There's a GCC (Clang) extension that enables support function
- deadalnix (5/24) Sep 11 2013 I think this is another form of the unclear qualifier binding
- Dicebot (3/7) Sep 11 2013 Yeah, giving tool to differ those can be an elegant way out of
- David Nadlinger (10/12) Sep 10 2013 I agree that this should not be legal. LDC detects this in the
I know that extern(C) functions cannot be legally overloaded, but
not issuing an error in the following situation seems wrong / a
bug:
extern(C) void foo(int);
extern(C) void foo() {}
void main()
{
foo(42);
}
Sep 10 2013
I just realized I wasn't clear -- it calls the (wrong) overloaded
function:
extern(C) void foo(int);
extern(C) void foo() { writeln("yes, this is called"); }
void main()
{
foo(42);
}
outputs:
yes, this is called
Sep 10 2013
On Tuesday, 10 September 2013 at 14:07:18 UTC, Luís Marques wrote:
I just realized I wasn't clear -- it calls the (wrong)
overloaded function:
extern(C) void foo(int);
extern(C) void foo() { writeln("yes, this is called"); }
void main()
{
foo(42);
}
outputs:
yes, this is called
This is why mixing ABI and mangling in one entity is bad. And why
overloading extern(C) functions is compile-time error in C++.
Sep 10 2013
On 2013-09-10 16:38, Dicebot wrote:This is why mixing ABI and mangling in one entity is bad. And why overloading extern(C) functions is compile-time error in C++.There's a GCC (Clang) extension that enables support function overloading in C. I guess it's a bit overkill to support in D. -- /Jacob Carlborg
Sep 11 2013
On Tuesday, 10 September 2013 at 14:38:56 UTC, Dicebot wrote:On Tuesday, 10 September 2013 at 14:07:18 UTC, Luís Marques wrote:I think this is another form of the unclear qualifier binding problem. Qualifier bind to symbol : mangling. Qualifier bind to type : calling convention.I just realized I wasn't clear -- it calls the (wrong) overloaded function: extern(C) void foo(int); extern(C) void foo() { writeln("yes, this is called"); } void main() { foo(42); } outputs: yes, this is calledThis is why mixing ABI and mangling in one entity is bad. And why overloading extern(C) functions is compile-time error in C++.
Sep 11 2013
On Wednesday, 11 September 2013 at 08:26:02 UTC, deadalnix wrote:I think this is another form of the unclear qualifier binding problem. Qualifier bind to symbol : mangling. Qualifier bind to type : calling convention.Yeah, giving tool to differ those can be an elegant way out of this inconvenience.
Sep 11 2013
On Tuesday, 10 September 2013 at 14:04:58 UTC, Luís Marques wrote:
extern(C) void foo(int);
extern(C) void foo() {}
I agree that this should not be legal. LDC detects this in the
glue layer (we would have to add a workaround for the
corresponding LLVM restriction otherwise):
---
$ ldc2 test.d
test.d(4): Error: Function type does not match previously
declared function with the same mangled name: foo
---
David
Sep 10 2013









Jacob Carlborg <doob me.com> 