Skip to content

const struct member becomes mut if type not defined #1747

@johalun

Description

@johalun

Input C/C++ Header

// Comment out this to turn *mut b -> *const b in generated Rust code.
#define BUG
#if !defined(BUG)
struct b;
#endif
struct a {
	const struct b *x;
};

Bindgen Invocation

$ bindgen input.h --no-layout-tests

Actual Results

/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct a {
    pub x: *mut b,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct b {
    pub _address: u8,
}

Expected Results

The struct member becomes const/mut depending on if it's defined or not.

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