I need this as well. I’m working on FFI bindings to the libbinder android library. It has a few structs that look like
struct flat_binder_object {
struct binder_object_header hdr;
__u32 flags;
/* 8 bytes of data. */
union {
binder_uintptr_t binder; /* local object */
__u32 handle; /* remote object */
};
/* extra data associated with local object */
binder_uintptr_t cookie;
};
or even deeper nesting of struct/union/struct. This leads bindgen to generate some fairly annoying code :
#[repr(C)]
#[derive(Copy)]
pub struct flat_binder_object {
pub type_: u32,
pub flags: u32,
pub __bindgen_anon_1: flat_binder_object__bindgen_ty_1,
pub cookie: binder_uintptr_t,
}
#[repr(C)]
#[derive(Copy)]
pub union flat_binder_object__bindgen_ty_1 {
pub binder: binder_uintptr_t,
pub handle: u32,
}
This is obviously sub-par. Having unlabeled fields would allow bindgen to generate “good” bindings.