diff options
author | Varphone Wong <varphone@qq.com> | 2020-08-04 14:04:35 +0800 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-08-04 12:08:11 +0200 |
commit | 1127561bb232fe0aa3ef48cc8404b26ed3b7116c (patch) | |
tree | 88ba3a7d5e0c1e23fb1ccd90b42883184c9b2864 | |
parent | 8e6a6999e9392d80c45979dd3f0d6ceca58db94e (diff) |
Move `__bindgen_anon_` to constant `DEFAULT_ANON_FIELDS_PREFIX`
-rw-r--r-- | src/lib.rs | 11 | ||||
-rw-r--r-- | src/options.rs | 4 |
2 files changed, 10 insertions, 5 deletions
@@ -94,6 +94,9 @@ type HashMap<K, V> = ::rustc_hash::FxHashMap<K, V>; type HashSet<K> = ::rustc_hash::FxHashSet<K>; pub(crate) use std::collections::hash_map::Entry; +/// Default prefix for the anon fields. +pub const DEFAULT_ANON_FIELDS_PREFIX: &'static str = "__bindgen_anon_"; + fn args_are_cpp(clang_args: &[String]) -> bool { return clang_args .windows(2) @@ -385,8 +388,10 @@ impl Builder { output_vector.push(prefix.clone()); } - output_vector.push("--anon-fields-prefix".into()); - output_vector.push(self.options.anon_fields_prefix.clone()); + if self.options.anon_fields_prefix != DEFAULT_ANON_FIELDS_PREFIX { + output_vector.push("--anon-fields-prefix".into()); + output_vector.push(self.options.anon_fields_prefix.clone()); + } if self.options.emit_ast { output_vector.push("--emit-clang-ast".into()); @@ -1821,7 +1826,7 @@ impl Default for BindgenOptions { disable_header_comment: false, use_core: false, ctypes_prefix: None, - anon_fields_prefix: "__bindgen_anon_".into(), + anon_fields_prefix: DEFAULT_ANON_FIELDS_PREFIX.into(), namespaced_constants: true, msvc_mangling: false, convert_floats: true, diff --git a/src/options.rs b/src/options.rs index 4844b91a..1ba349a9 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,6 +1,6 @@ use bindgen::{ builder, AliasVariation, Builder, CodegenConfig, EnumVariation, RustTarget, - RUST_TARGET_STRINGS, + DEFAULT_ANON_FIELDS_PREFIX, RUST_TARGET_STRINGS, }; use clap::{App, Arg}; use std::fs::File; @@ -238,7 +238,7 @@ where .long("anon-fields-prefix") .help("Use the given prefix for the anon fields.") .value_name("prefix") - .default_value("__bindgen_anon_") + .default_value(DEFAULT_ANON_FIELDS_PREFIX) .takes_value(true), Arg::with_name("time-phases") .long("time-phases") |