Open
Description
I would like to know if is possible to suggest to bindgen a name for anonymous unions.
For example, if I have this structure:
typedef struct
{
unsigned int tCL;
union {
unsigned int tRCD;
unsigned int tRCD_RD;
};
unsigned int tRCD_WR,
tRP,
tRAS,
tRC,
tRCPB,
tRPPB;
union {
unsigned int tRRD;
unsigned int tRRDS;
};
unsigned int tRRDL,
tRRDDLR,
tFAW,
tFAWSLR,
tFAWDLR,
tWTRS,
tWTRL,
tWR;
} RAM_TIMING;
bindgen generates a rust struct like this:
#[repr(C)]
#[derive(Copy, Clone)]
pub struct RAM_TIMING {
pub tCL: ::std::os::raw::c_uint,
pub __bindgen_anon_1: RAM_TIMING__bindgen_ty_1,
pub tRCD_WR: ::std::os::raw::c_uint,
pub tRP: ::std::os::raw::c_uint,
pub tRAS: ::std::os::raw::c_uint,
pub tRC: ::std::os::raw::c_uint,
pub tRCPB: ::std::os::raw::c_uint,
pub tRPPB: ::std::os::raw::c_uint,
pub __bindgen_anon_2: RAM_TIMING__bindgen_ty_2,
pub tRRDL: ::std::os::raw::c_uint,
pub tRRDDLR: ::std::os::raw::c_uint,
pub tFAW: ::std::os::raw::c_uint,
pub tFAWSLR: ::std::os::raw::c_uint,
pub tFAWDLR: ::std::os::raw::c_uint,
pub tWTRS: ::std::os::raw::c_uint,
pub tWTRL: ::std::os::raw::c_uint,
pub tWR: ::std::os::raw::c_uint
}
I was wondering if there is a way to specify a name for all the anonymous fiels, like __bindgen_anon_1
and RAM_TIMING__bindgen_ty_1
.
I don't know if it makes sense, but I was hoping to be able to do something like:
typedef struct
{
unsigned int tCL;
/// <div rustbindgen name="tRCD_u"></div>
union {
unsigned int tRCD;
unsigned int tRCD_RD;
};
[...]
to generate something like this:
#[repr(C)]
#[derive(Copy, Clone)]
pub struct RAM_TIMING {
pub tCL: ::std::os::raw::c_uint,
pub tRCD_u: RAM_TIMING__tRCD_u,
[...]
Unfortunately I cannot simply give a name to the union. If the comment solution is not possible, is there any other way to control the name used by the generated code in case of anonymous unions?