This is a spin-off of bug 5069 (On request of yebblies too). This is a wrong D2 program: import std.c.stdlib: qsort; import std.c.stdio: printf; int compare(const void *a, const void *b) { return *cast(int*)a - *cast(int*)b; } void main () { int[] values = [40, 10, 100, 90, 20, 25]; for (int n = 0; n < 6; n++) printf ("%d ", values[n]); printf("\n"); qsort(values.ptr, 6, int.sizeof, &compare); for (int n = 0; n < 6; n++) printf ("%d ", values[n]); printf("\n"); } With dmd 2.055head it prints: test.d(11): Error: function core.stdc.stdlib.qsort (void* base, uint nmemb, uint size, int C function(in const(void*), in const(void*)) compar) is not callable using argument types (int*,int,uint,int function(in const(void*), in const(void*))) test.d(11): Error: cannot implicitly convert expression (& compare) of type int function(in const(void*), in const(void*)) to int C function(in const(void*), in const(void*)) I'd like it to print: int extern(C) function(in const(void*), in const(void*)) Instead of: int C function(in const(void*), in const(void*)) Because it's easy to miss a single C in the noise of the error message, and because it's closer to the code that you actually have to write. Even better is to produce a single error message, reducing the clutter: test.d(11): Error: cannot implicitly convert expression (&compare) of type int function(in const(void*), in const(void*)) to int extern(C) function(in const(void*), in const(void*))
Reduce test case: ---- extern (C) int function() pfunc; extern (C) int cfunc(){ return 0; } // current behavior static assert(typeof(pfunc).stringof == "int C function()"); static assert(typeof(cfunc).stringof == "intC ()"); // expect (1) static assert(typeof(pfunc).stringof == "int extern (C) function()"); static assert(typeof(cfunc).stringof == "int extern (C) ()"); // expect (2) static assert(typeof(pfunc).stringof == "extern (C) int function()"); static assert(typeof(cfunc).stringof == "extern (C) int()"); ---- I think #2 is more better.
https://github.com/D-Programming-Language/dmd/pull/404 Implements: (In reply to comment #1) > extern (C) int function() pfunc; > extern (C) int cfunc(){ return 0; } > [snip] > > // expect (2) > static assert(typeof(pfunc).stringof == "extern (C) int function()"); > static assert(typeof(cfunc).stringof == "extern (C) int()");
https://github.com/D-Programming-Language/dmd/commit/15f54382fb89671c1c640d8b7c11da3b3b923aa1
Thank you. But is "in const(void*)" correct? Aren't "in void*" or "const(void*)" or "const void*" enough?