Skip to content

Bindgen is not respecting .derive_debug(true) for a generated struct that works with #[derive(Debug)] #2041

Closed

Description

Input C/C++ Header

#include <linux/dm-ioctl.h>

Bindgen Invocation

    let bindings = Builder::default()         
        .header("dm-ioctl.h")   
        .derive_debug(true)                                               
        .derive_default(true)                                                                                                                                                                                                                 
        .generate()                                                                                                                                                                                                                           
        .expect("Could not generate bindings");                                                                                                                                                                                               

Actual Results

#[repr(C)]                                                                                                                                                                                                                          [421/1915]
#[derive(Copy, Clone)]                                                                                                                                                                                                                        
pub struct dm_ioctl {                                                                                                  
    pub version: [__u32; 3usize],                                                                                      
    pub data_size: __u32,                                  
    pub data_start: __u32,                                                                                             
    pub target_count: __u32,                                                                                           
    pub open_count: __s32,                                                                                             
    pub flags: __u32,                                                                                                  
    pub event_nr: __u32,                                                                                                                                                                                                                      
    pub padding: __u32,                                                                                                
    pub dev: __u64,                                                                                                    
    pub name: [::std::os::raw::c_char; 128usize],                                                                      
    pub uuid: [::std::os::raw::c_char; 129usize],                                                                      
    pub data: [::std::os::raw::c_char; 7usize],
}                                                          

Expected Results

I would expect dm_ioctl to have a #[derive(Debug)]. I tested this generated struct in the Rust playground and it successfully derives Debug when the directive is added. Was this an intentional design decision or does this appear to be a bug? Default appears not to be implemented for some of the members of the struct so that part makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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