rust-lang / rust-lang/rust-bindgen
some unknown generating when default value is set in c
Open
Nobody has claimed this yet.
I-needs-reduced-test-case
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
here is my input structure.
typedef struct {
const char *base_path; /**< Mounting point. */
const char *partition_label; /**< Label of partition to use. */
uint8_t format_if_mount_failed:1; /**< Format the file system if it fails to mount. */
uint8_t dont_mount:1; /**< Don't attempt to mount or format. Overrides format_if_mount_failed */
} esp_vfs_littlefs_conf_t;
Bindgen Invocation
let builder = bindgen::Builder::default()
.use_core()
.layout_tests(false)
.rustfmt_bindings(false)
.derive_default(true)
.clang_arg("-D__bindgen")
// Include directories provided by the build system
// should be first on the search path (before sysroot includes),
// or else libc's <dirent.h> does not correctly override sysroot's <dirent.h>
.clang_args(&self.clang_args)
.clang_args(sysroot_args)
.clang_args(&["-x", if cpp { "c++" } else { "c" }])
.clang_args(cpp_args);
Actual Results
#[doc = "Configuration structure for esp_vfs_littlefs_register."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct esp_vfs_littlefs_conf_t {
#[doc = "< Mounting point."]
pub base_path: *const c_types::c_char,
#[doc = "< Label of partition to use."]
pub partition_label: *const c_types::c_char,
pub _bitfield_align_1: [u8; 0],
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
pub __bindgen_padding_0: [u8; 3usize],
}
Expected Results
#[doc = "Configuration structure for esp_vfs_littlefs_register."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct esp_vfs_littlefs_conf_t {
#[doc = "< Mounting point."]
pub base_path: *const c_types::c_char,
#[doc = "< Label of partition to use."]
pub partition_label: *const c_types::c_char,
#[doc = "< Format the file system if it fails to mount."]
pub format_if_mount_failed: u8,
#[doc = "< Don't attempt to mount or format. Overrides format_if_mount_failed"]
pub dont_mount: u8,
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generated bindings from the esp_vfs_littlefs_conf_t input and the shown bindgen::Builder invocation, then trace how the two C bitfields become _bitfield_1 and padding. Done means the generated Rust struct exposes format_if_mount_failed and dont_mount as separate u8 fields with their documentation preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100