www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23045] New: importC: casted function type is missing extern(C)


          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 puremagic.com
          Reporter: duser neet.fi
                CC: duser 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
        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

Apr 21 2022