Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect return type when using __stdcall #1402

Closed
programmerjake opened this issue Sep 26, 2018 · 2 comments
Closed

Incorrect return type when using __stdcall #1402

programmerjake opened this issue Sep 26, 2018 · 2 comments
Assignees
Labels

Comments

@programmerjake
Copy link
Member

I'm using bindgen version 0.40

Input C/C++ Header

typedef void (__stdcall *void_fn)();
typedef void_fn (__stdcall *fn)(int id);

Bindgen Invocation

    let builder = bindgen::builder()
        .header_contents(
            "header.h",
            r#"
typedef void (__stdcall *void_fn)();
typedef void_fn (__stdcall *fn)(int id);
"#
        ).clang_arg("-target")
        .clang_arg("i686-pc-windows-msvc")
        .prepend_enum_name(false)
        .layout_tests(false)
        .constified_enum(".*");
    let code = builder
        .generate()
        .map_err(|_| io::Error::new(io::ErrorKind::Other, "generate() failed"))?
        .to_string();
    println!("{}", code);

Actual Results

/* automatically generated by rust-bindgen */

pub type void_fn = ::std::option::Option<unsafe extern "stdcall" fn()>;
pub type fn_ = ::std::option::Option<
    unsafe extern "stdcall" fn(
        id: ::std::os::raw::c_int
    ) -> ::std::option::Option<
        unsafe extern "stdcall" fn(id: ::std::os::raw::c_int, ...),
    >,
>;

Expected Results

pub type void_fn = ::std::option::Option<unsafe extern "stdcall" fn()>;
pub type fn_ = ::std::option::Option<
    unsafe extern "stdcall" fn(
        id: ::std::os::raw::c_int
    ) -> void_fn,
>;

I expect the return type of fn_ to have no arguments.

@emilio
Copy link
Contributor

emilio commented Sep 26, 2018

Huh, this is a fun one, thanks!

emilio added a commit to emilio/rust-bindgen that referenced this issue Sep 26, 2018
@emilio emilio self-assigned this Sep 26, 2018
@emilio emilio added the bug label Sep 26, 2018
@emilio
Copy link
Contributor

emilio commented Sep 26, 2018

This is the hack added in #549 biting us back. #1403 should have a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants