[Issue 23045] New: importC: casted function type is missing extern(C)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 22 00:55:10 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23045

          Issue ID: 23045
           Summary: importC: casted function type is missing extern(C)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, wrong-code
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: duser at neet.fi
                CC: duser at neet.fi

int printf(char *, ...);
void other(int a, int b)
{ 
        printf("a=%d b=%d\n", a, b);
}
int main()
{
        // called like extern(D)
        ((void (*)(int, int))other)(1, 2);

        // Error: incompatible types for `(cast(void function(int, int))&
other) is (other)`: `void function(int, int)` and `extern (C) void(int a, int
b)`
        if (((void (*)(int, int))other) == other)
                {}
}

on 64-bit linux, the call prints "a=2 b=1" since arguments to extern(D)
functions are passed in reverse order

--


More information about the Digitalmars-d-bugs mailing list