Skip to content

ImportC: confusing failed conversion from K&R variadics to empty parameter list #23177

@dkorpel

Description

@dkorpel

https://forum.dlang.org/post/xhdzoofhirdhfgsgndvq@forum.dlang.org

Officially an empty parameter list in C is f(void), but it's easily conflated with the modern way f(), which currently gives an uninformative message:

--- test_kr_callback.d
import kr_callback;

extern (C) int callback() {
    return 42;
}

void main()
{
    run(&callback); // cannot pass argument `& callback` of type `extern (C) int function()` to parameter `extern (C) int function() fn`
}


--- kr_callback.c
typedef int(*fp)();

int run(fp fn) {
    return fn();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions