Skip to content

Commit 1127561

Browse files
varphoneemilio
authored andcommitted
Move __bindgen_anon_ to constant DEFAULT_ANON_FIELDS_PREFIX
1 parent 8e6a699 commit 1127561

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ type HashMap<K, V> = ::rustc_hash::FxHashMap<K, V>;
9494
type HashSet<K> = ::rustc_hash::FxHashSet<K>;
9595
pub(crate) use std::collections::hash_map::Entry;
9696

97+
/// Default prefix for the anon fields.
98+
pub const DEFAULT_ANON_FIELDS_PREFIX: &'static str = "__bindgen_anon_";
99+
97100
fn args_are_cpp(clang_args: &[String]) -> bool {
98101
return clang_args
99102
.windows(2)
@@ -385,8 +388,10 @@ impl Builder {
385388
output_vector.push(prefix.clone());
386389
}
387390

388-
output_vector.push("--anon-fields-prefix".into());
389-
output_vector.push(self.options.anon_fields_prefix.clone());
391+
if self.options.anon_fields_prefix != DEFAULT_ANON_FIELDS_PREFIX {
392+
output_vector.push("--anon-fields-prefix".into());
393+
output_vector.push(self.options.anon_fields_prefix.clone());
394+
}
390395

391396
if self.options.emit_ast {
392397
output_vector.push("--emit-clang-ast".into());
@@ -1821,7 +1826,7 @@ impl Default for BindgenOptions {
18211826
disable_header_comment: false,
18221827
use_core: false,
18231828
ctypes_prefix: None,
1824-
anon_fields_prefix: "__bindgen_anon_".into(),
1829+
anon_fields_prefix: DEFAULT_ANON_FIELDS_PREFIX.into(),
18251830
namespaced_constants: true,
18261831
msvc_mangling: false,
18271832
convert_floats: true,

src/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bindgen::{
22
builder, AliasVariation, Builder, CodegenConfig, EnumVariation, RustTarget,
3-
RUST_TARGET_STRINGS,
3+
DEFAULT_ANON_FIELDS_PREFIX, RUST_TARGET_STRINGS,
44
};
55
use clap::{App, Arg};
66
use std::fs::File;
@@ -238,7 +238,7 @@ where
238238
.long("anon-fields-prefix")
239239
.help("Use the given prefix for the anon fields.")
240240
.value_name("prefix")
241-
.default_value("__bindgen_anon_")
241+
.default_value(DEFAULT_ANON_FIELDS_PREFIX)
242242
.takes_value(true),
243243
Arg::with_name("time-phases")
244244
.long("time-phases")

0 commit comments

Comments
 (0)