Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float constants with exponents are not parsed in macros #1928

Open
cjordan opened this issue Nov 22, 2020 · 2 comments
Open

Float constants with exponents are not parsed in macros #1928

cjordan opened this issue Nov 22, 2020 · 2 comments

Comments

@cjordan
Copy link

cjordan commented Nov 22, 2020

Input C/C++ Header

/* Radians to arcseconds */
#define ERFA_DR2AS (206264.8062470963551564734)

/* Arcseconds to radians */
#define ERFA_DAS2R (4.848136811095359935899141e-6)

Bindgen Invocation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen 0.55.1 */

pub const ERFA_DR2AS: f64 = 206264.80624709636;

With debugging output:

[2020-11-22T11:14:39Z INFO  bindgen] Clang Version: clang version 11.0.0, parsed: Some((11, 0))
[2020-11-22T11:14:39Z DEBUG bindgen] Generating bindings, libclang at /usr/lib64/libclang.so.11
[2020-11-22T11:14:39Z DEBUG bindgen] Trying to find clang with flags: []
[2020-11-22T11:14:39Z DEBUG bindgen] Found clang: Clang { path: "/usr/bin/clang", version: Some(CXVersion { Major: 11, Minor: 0, Subminor: 0 }), c_search_paths: Some(["/usr/local/include", "/usr/lib/clang/11.0.0/include", "/usr/include"]), cpp_search_paths: Some(["/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0", "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/x86_64-pc-linux-gnu", "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/backward", "/usr/local/include", "/usr/lib/clang/11.0.0/include", "/usr/include"]) }
[2020-11-22T11:14:39Z DEBUG bindgen] Fixed-up options: BindgenOptions { blacklisted_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, blacklisted_functions: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, blacklisted_items: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, opaque_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, rustfmt_path: None, whitelisted_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, whitelisted_functions: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, whitelisted_vars: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, default_enum_style: Consts, bitfield_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, newtype_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, rustified_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, rustified_non_exhaustive_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, constified_enum_modules: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, constified_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, default_macro_constant_type: Unsigned, default_alias_style: TypeAlias, type_alias: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, new_type_alias: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, new_type_alias_deref: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, builtins: false, emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, enable_function_attribute_detection: false, disable_name_namespacing: false, disable_nested_struct_naming: false, disable_header_comment: false, layout_tests: true, impl_debug: false, impl_partialeq: false, derive_copy: true, derive_debug: true, derive_default: false, derive_hash: false, derive_partialord: false, derive_ord: false, derive_partialeq: false, derive_eq: false, use_core: false, ctypes_prefix: None, anon_fields_prefix: "__bindgen_anon_", time_phases: false, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], module_lines: {}, clang_args: ["-isystem", "/usr/local/include", "-isystem", "/usr/lib/clang/11.0.0/include", "-isystem", "/usr/include", "test.h"], input_header: Some("test.h"), input_unsaved_files: [], parse_callbacks: None, codegen_config: FUNCTIONS | TYPES | VARS | METHODS | CONSTRUCTORS | DESTRUCTORS, conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: false, whitelist_recursively: true, objc_extern_crate: false, generate_block: false, block_extern_crate: false, enable_mangling: true, detect_include_paths: true, prepend_enum_name: true, rust_target: Stable_1_40, rust_features: RustFeatures { untagged_union: true, associated_const: true, builtin_clone_impls: true, repr_align: true, i128_and_u128: true, must_use_function: true, repr_transparent: true, min_const_fn: true, core_ffi_c_void: true, repr_packed_n: true, maybe_uninit: true, non_exhaustive: true, thiscall_abi: false }, record_matches: true, size_t_is_usize: false, rustfmt_bindings: true, rustfmt_configuration_file: None, no_partialeq_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, no_copy_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, no_debug_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, no_hash_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, array_pointers_in_arguments: false, wasm_import_module_name: None }
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] BindgenContext::add_item(Item { id: ItemId(1), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Float(Double), is_const: true }) }, declaration: None, loc: None
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] add_item_to_module: adding ItemId(1) as child of parent module ItemId(0)
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] BindgenContext::add_item(Item { id: ItemId(2), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Var(Var { name: "ERFA_DR2AS", mangled_name: None, ty: TypeId(ItemId(1)), val: Some(Float(206264.80624709636)), is_const: true }) }, declaration: Some(Cursor(ERFA_DR2AS kind: macro definition, loc: test.h:2:9, usr: Some("c:test.h@36@macro@ERFA_DR2AS"))), loc: Some(Cursor(ERFA_DR2AS kind: macro definition, loc: test.h:2:9, usr: Some("c:test.h@36@macro@ERFA_DR2AS")))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] add_item_to_module: adding ItemId(2) as child of parent module ItemId(0)
[2020-11-22T11:14:39Z DEBUG bindgen::ir::item] Item::from_ty_with_id: ItemId(3)
    	ty = Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
    	location = Cursor(ERFA_DAS2R kind: macro definition, loc: test.h:5:9, usr: Some("c:test.h@113@macro@ERFA_DAS2R"))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] builtin_or_resolved_ty: Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(ERFA_DAS2R kind: macro definition, loc: test.h:5:9, usr: Some("c:test.h@113@macro@ERFA_DAS2R"))), Some(ItemId(0))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] Not resolved, maybe builtin?
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] builtin_or_resolved_ty: Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(ERFA_DAS2R kind: macro definition, loc: test.h:5:9, usr: Some("c:test.h@113@macro@ERFA_DAS2R"))), Some(ItemId(0))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] Not resolved, maybe builtin?
[2020-11-22T11:14:39Z DEBUG bindgen::ir::ty] from_clang_ty: ItemId(3), ty: Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(ERFA_DAS2R kind: macro definition, loc: test.h:5:9, usr: Some("c:test.h@113@macro@ERFA_DAS2R"))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::ty] currently_parsed_types: []
[2020-11-22T11:14:39Z WARN  bindgen::ir::ty] invalid type Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::item] Unhandled cursor kind 501: Cursor(ERFA_DAS2R kind: macro definition, loc: test.h:5:9, usr: Some("c:test.h@113@macro@ERFA_DAS2R"))
[2020-11-22T11:14:39Z DEBUG bindgen::ir::context] No replacements to process
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_vtable] constrain ItemId(2)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_vtable] constrain ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_vtable] constrain ItemId(0)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::sizedness] constrain TypeId(ItemId(1))
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::sizedness]     Float(Double) is known not to be zero-sized
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::sizedness] inserting NonZeroSized for TypeId(ItemId(1))
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params] constrain ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   initially, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]     other item: join with successors' usage
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   finally, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params] constrain ItemId(2)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   initially, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]     other item: join with successors' usage
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]       union with ItemId(1)'s usage: []
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   finally, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params] constrain ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   initially, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]     other item: join with successors' usage
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   finally, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params] constrain ItemId(0)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   initially, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]     other item: join with successors' usage
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::template_params]   finally, used set is {}
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] ty: Type { name: None, layout: None, kind: Float(Double), is_const: true }
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     simple type that can always derive Debug
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(1) can_derive<Debug>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(2)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     member ItemId(1) can derive Debug
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(2) can_derive<Debug>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] ty: Type { name: None, layout: None, kind: Float(Double), is_const: true }
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     simple type that can always derive Debug
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(1) can_derive<Debug>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(0)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     can derive Debug because there are no members
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(0) can_derive<Debug>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] ty: Type { name: None, layout: None, kind: Float(Double), is_const: true }
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     simple type that can always derive Copy
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(1) can_derive<Copy>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(2)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     member ItemId(1) can derive Copy
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(2) can_derive<Copy>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] ty: Type { name: None, layout: None, kind: Float(Double), is_const: true }
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     simple type that can always derive Copy
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(1) can_derive<Copy>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] constrain: ItemId(0)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive]     can derive Copy because there are no members
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::derive] inserting ItemId(0) can_derive<Copy>=Yes
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_type_param_in_array] constrain: ItemId(2)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_type_param_in_array]     not a type; ignoring
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_type_param_in_array] constrain: ItemId(1)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_type_param_in_array]     simple type that do not have array
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_type_param_in_array] constrain: ItemId(0)
[2020-11-22T11:14:39Z TRACE bindgen::ir::analysis::has_type_param_in_array]     not a type; ignoring
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] codegen: BindgenOptions { blacklisted_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, blacklisted_functions: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, blacklisted_items: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, opaque_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, rustfmt_path: None, whitelisted_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, whitelisted_functions: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, whitelisted_vars: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, default_enum_style: Consts, bitfield_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, newtype_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, rustified_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, rustified_non_exhaustive_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, constified_enum_modules: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, constified_enums: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, default_macro_constant_type: Unsigned, default_alias_style: TypeAlias, type_alias: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, new_type_alias: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, new_type_alias_deref: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, builtins: false, emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, enable_function_attribute_detection: false, disable_name_namespacing: false, disable_nested_struct_naming: false, disable_header_comment: false, layout_tests: true, impl_debug: false, impl_partialeq: false, derive_copy: true, derive_debug: true, derive_default: false, derive_hash: false, derive_partialord: false, derive_ord: false, derive_partialeq: false, derive_eq: false, use_core: false, ctypes_prefix: None, anon_fields_prefix: "__bindgen_anon_", time_phases: false, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], module_lines: {}, clang_args: ["-isystem", "/usr/local/include", "-isystem", "/usr/lib/clang/11.0.0/include", "-isystem", "/usr/include", "test.h"], input_header: Some("test.h"), input_unsaved_files: [], parse_callbacks: None, codegen_config: FUNCTIONS | TYPES | VARS | METHODS | CONSTRUCTORS | DESTRUCTORS, conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: false, whitelist_recursively: true, objc_extern_crate: false, generate_block: false, block_extern_crate: false, enable_mangling: true, detect_include_paths: true, prepend_enum_name: true, rust_target: Stable_1_40, rust_features: RustFeatures { untagged_union: true, associated_const: true, builtin_clone_impls: true, repr_align: true, i128_and_u128: true, must_use_function: true, repr_transparent: true, min_const_fn: true, core_ffi_c_void: true, repr_packed_n: true, maybe_uninit: true, non_exhaustive: true, thiscall_abi: false }, record_matches: true, size_t_is_usize: false, rustfmt_bindings: true, rustfmt_configuration_file: None, no_partialeq_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, no_copy_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, no_debug_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, no_hash_types: RegexSet { items: [], matched: [], set: Some(RegexSet([])), record_matches: true }, array_pointers_in_arguments: false, wasm_import_module_name: None }
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] <Item as CodeGenerator>::codegen: self = Item { id: ItemId(0), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2)} }) }
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] <Module as CodeGenerator>::codegen: item = Item { id: ItemId(0), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2)} }) }
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] <Item as CodeGenerator>::codegen: self = Item { id: ItemId(1), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Float(Double), is_const: true }) }
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] <Type as CodeGenerator>::codegen: item = Item { id: ItemId(1), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Float(Double), is_const: true }) }
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] <Item as CodeGenerator>::codegen: self = Item { id: ItemId(2), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Var(Var { name: "ERFA_DR2AS", mangled_name: None, ty: TypeId(ItemId(1)), val: Some(Float(206264.80624709636)), is_const: true }) }
[2020-11-22T11:14:39Z DEBUG bindgen::codegen] <Var as CodeGenerator>::codegen: item = Item { id: ItemId(2), local_id: LazyCell { inner: UnsafeCell }, next_child_local_id: Cell { value: 1 }, canonical_name: LazyCell { inner: UnsafeCell }, path_for_whitelisting: LazyCell { inner: UnsafeCell }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, disallow_debug: false, private_fields: None, accessor_kind: None, constify_enum_variant: false, derives: [] }, parent_id: ItemId(0), kind: Var(Var { name: "ERFA_DR2AS", mangled_name: None, ty: TypeId(ItemId(1)), val: Some(Float(206264.80624709636)), is_const: true }) }
/* automatically generated by rust-bindgen 0.55.1 */

pub const ERFA_DR2AS: f64 = 206264.80624709636;

Expected Results

/* automatically generated by rust-bindgen 0.55.1 */

pub const ERFA_DR2AS: f64 = 206264.80624709636;
pub const ERFA_DAS2R: f64 = 4.848136811095359935899141e-6;

Commentary

Hi, hopefully I've not missed something and this is a real bug. I think the example is quite clear. I would have a crack at fixing the issue on my own, but the debugging output has sufficiently terrified me.

The example is derived from erfam.h, although this include file gets pulled in from erfa.h in the same directory (so only erfa.h is needed to be fed to bindgen).

Thanks for bindgen!

@emilio
Copy link
Contributor

emilio commented Nov 25, 2020

I think this bug should be reported to https://github.com/jethrogb/rust-cexpr which is what we use to generate constants from C macros. As a workaround, something like this:

static const double ERFA_DAS2R = 4.848136811095359935899141e-6;

Or static const double MY_ERFA_DAS2R = ERFA_DAS2R; uses clang to evaluate them and works.

The later should be usable even if you don't have control over the C header.

@emilio
Copy link
Contributor

emilio commented Nov 25, 2020

#1782 might fix this as well.

@emilio emilio changed the title Float constants with exponents are not parsed Float constants with exponents are not parsed in macros Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants