Skip to content

Inappropriate generated type for function-returning-function #2713

Open

Description

Input C/C++ Header

void (*(*xDlSym)(const char *))(void);

Bindgen Invocation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen 0.69.1 */

extern "C" {
    pub static mut xDlSym: ::std::option::Option<
        unsafe extern "C" fn(
            arg3: *const ::std::os::raw::c_char,
        ) -> ::std::option::Option<
            unsafe extern "C" fn(
                arg3: *const ::std::os::raw::c_char,
            ),
        >,
    >;
}

Expected Results

extern "C" {
    pub static mut xDlSym: ::std::option::Option<
        unsafe extern "C" fn(
            arg3: *const ::std::os::raw::c_char,
        ) -> ::std::option::Option<
            unsafe extern "C" fn(
-               arg3: *const ::std::os::raw::c_char,
            ),
        >,
    >;
}

The original C signature is hard to read: it describes a function pointer xDlSym that takes a single const char * argument and returns another function pointer of type void (*)(void). But in the bindgen-generated output, the returned function pointer has the inappropriate type void (*)(const char *) instead.

This affects the public API of libsqlite3-sys here; the reproducer is minimized from that situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions