Skip to content

Commit

Permalink
Make size_t_is_usize default to true
Browse files Browse the repository at this point in the history
This addresses the first part of rust-lang#1901.

If size_t_is_usize is manually set to false, and bindgen encounters
any size_t, then we should also probably test to confirm that size_t
is congruent to uintptr_t on the current platform.  I'm not sure of
the best way to do this check.
  • Loading branch information
dkg committed Oct 16, 2020
1 parent a467d3e commit 844d99d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ impl Default for BindgenOptions {
time_phases: false,
record_matches: true,
rustfmt_bindings: true,
size_t_is_usize: false,
size_t_is_usize: true,
rustfmt_configuration_file: None,
no_partialeq_types: Default::default(),
no_copy_types: Default::default(),
Expand Down
15 changes: 14 additions & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ where
),
Arg::with_name("size_t-is-usize")
.long("size_t-is-usize")
.help("Translate size_t to usize."),
.help("Translate size_t to usize. (this is the default)"),
Arg::with_name("size_t-is-not-usize")
.long("size_t-is-not-usize")
.help("Translate size_t to platform-specific lengths."),
Arg::with_name("no-rustfmt-bindings")
.long("no-rustfmt-bindings")
.help("Do not format the generated bindings with rustfmt."),
Expand Down Expand Up @@ -815,6 +818,16 @@ where

if matches.is_present("size_t-is-usize") {
builder = builder.size_t_is_usize(true);
if matches.is_present("size_t-is-not-usize") {
return Err(Error::new(
ErrorKind::Other,
"Cannot supply both --size_t-is-usize and --size_t-is-not-usize",
));
}
}

if matches.is_present("size_t-is-not-usize") {
builder = builder.size_t_is_usize(false);
}

let no_rustfmt_bindings = matches.is_present("no-rustfmt-bindings");
Expand Down

0 comments on commit 844d99d

Please sign in to comment.