Skip to content

Falls back to BindgenUnion if a field is array of blacklisted type #1223

Open
@faern

Description

@faern

When I blacklist a type (because I want to import it from libc, not have it generated in my bindings.) Then bindgen fails to generate a union if a field in the C union has a field being an array of the blacklisted type, but not if the field has the same type, but isn't an array.

Input C/C++ Header

Correctly generats a union:

typedef int __u32;
union my_union {
    __u32       number;
};

Instead generates a BindgenUnion:

typedef int __u32;
union my_union {
    __u32       number[4];
};

Bindgen Invocation

$ bindgen union.h --blacklist-type __u32 --raw-line 'use libc::__u32;'

Actual Results

With first input header (no array):

#[repr(C)]
pub union my_union {
    pub number: __u32,
    _bindgen_union_align: u32,
}

With second input header, having an array in the union.

#[repr(C)]
pub struct my_union {
    pub number: __BindgenUnionField<[__u32; 4usize]>,
    pub bindgen_union_field: [u32; 4usize],
}

Expected Results

Both __u32 and [__u32; 4usize] should implement Copy and thus both should yield a union in the generated code.

EDIT: I'm using bindgen 0.32.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions