http://d.puremagic.com/issues/show_bug.cgi?id=6596

           Summary: Error message with not extern(C) function
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-09-02 10:13:29 PDT ---
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*))

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to