Skip to content

Bindgen converts char to c_schar instead of c_char #603

@crumblingstatue

Description

@crumblingstatue

Input C/C++ Header

struct foo {
	char member;
};

Bindgen Invokation

bindgen foo.h

Actual Results

/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy)]
pub struct foo {
    pub member: ::std::os::raw::c_schar,
}
#[test]
fn bindgen_test_layout_foo() {
    assert_eq!(::std::mem::size_of::<foo>() , 1usize , concat ! (
               "Size of: " , stringify ! ( foo ) ));
    assert_eq! (::std::mem::align_of::<foo>() , 1usize , concat ! (
                "Alignment of " , stringify ! ( foo ) ));
    assert_eq! (unsafe {
                & ( * ( 0 as * const foo ) ) . member as * const _ as usize }
                , 0usize , concat ! (
                "Alignment of field: " , stringify ! ( foo ) , "::" ,
                stringify ! ( member ) ));
}
impl Clone for foo {
    fn clone(&self) -> Self { *self }
}

Expected Results

The field should be c_char, not c_schar. char is not defined as always signed in the C standard. It can be unsigned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions