int C function
bearophile
bearophileHUGS at lycos.com
Sat Oct 1 03:04:49 PDT 2011
Ellery Newcomer:
> weird error. anyone know what's going on?
It's a good error message. In DMD 2.056head gives an even better error message:
test6.d(8): Error: function test6.X.tt (int function(const const(char*)) xz) is not callable using argument types (extern (C) int function(const const(char*) s))
test6.d(8): Error: cannot implicitly convert expression (& puts) of type extern (C) int function(const const(char*) s) to int function(const const(char*))
But the error message is not good enough yet, because "const const(char*)" needs to be written "const(char*)".
----------------------
Andrej Mitrovic:
> I think this is a side-effect of the new function pointer fixes, where
> you now can't implicitly convert an extern(C) function to an extern(D)
> function by accident (and that's a good thing).
I think it didn't perform a conversion, it just used to produce wrong code.
> But the problem is,
> you can't define a function with a different linkage type inline as a
> type parameter.
Is this in Bugzilla already?
----------------------
Ellery Newcomer:
> wait, are there explicit ways to convert extern(C) funcs <-> extern(D) funcs?
Maybe a new future job for std.conv.to? (to convert a extern(C) func ponter to extern(D) func pointer).
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list