Skip to content

Inner union structs not generated #651

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

Closed
daschl opened this issue Apr 21, 2017 · 2 comments
Closed

Inner union structs not generated #651

daschl opened this issue Apr 21, 2017 · 2 comments

Comments

@daschl
Copy link

daschl commented Apr 21, 2017

Input C/C++ Header

https://github.com/couchbase/libcouchbase/blob/master/include/libcouchbase/couchbase.h#L275

struct lcb_create_st {
    /** Indicates which field in the @ref lcb_CRST_u union should be used. Set this to `3` */
    int version;

    /**This union contains the set of current and historical options. The
     * The #v3 field should be used. */
    union lcb_CRST_u {
        struct lcb_create_st0 v0;
        struct lcb_create_st1 v1;
        struct lcb_create_st2 v2;
        struct lcb_create_st3 v3; /**< Use this field */
    } v;
    LCB_DEPR_CTORS_CRST
};

Bindgen Invokation

    let _ = bindgen::builder()
        .header("headers.h")
        .clang_arg("-I")
        .clang_arg(bindgen_path)
        .no_unstable_rust()
        .generate_comments(false)
        .generate()
        .unwrap()
        .write_to_file(Path::new(out_dir).join("bindings.rs"));

Actual Results

error[E0412]: cannot find type `lcb_create_st_lcb_CRST_u` in this scope
    --> /Users/daschl/code/rust/couchbase-rs/target/debug/build/couchbase-sys-4dafd1d829eed0ef/out/bindings.rs:3635:12
     |
3635 |     pub v: lcb_create_st_lcb_CRST_u,
     |            ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0204]: the trait `Copy` may not be implemented for this type
    --> /Users/daschl/code/rust/couchbase-rs/target/debug/build/couchbase-sys-4dafd1d829eed0ef/out/bindings.rs:3632:17
     |
3632 | #[derive(Debug, Copy)]
     |                 ^^^^
...
3635 |     pub v: lcb_create_st_lcb_CRST_u,
     |     ------------------------------- this field does not implement `Copy`

error: aborting due to previous error
#[repr(C)]
#[derive(Debug, Copy)]
pub struct lcb_create_st {
    pub version: ::std::os::raw::c_int,
    pub v: lcb_create_st_lcb_CRST_u,
}

Expected Results

I think the problem is that lcb_create_st expects lcb_create_st_lcb_CRST_u but its not created. I've been upgrading from 0.21 which used to work, but its broken since 0.22 I think (and is broken right now I tried 0.23.1).

@emilio
Copy link
Contributor

emilio commented Apr 21, 2017

Can you check on master? It's likely a dupe of #643

@daschl
Copy link
Author

daschl commented Apr 21, 2017

yes that indeed seems to fix it - thanks!

@daschl daschl closed this as completed Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants