We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This used to work with libbindgen 0.1.7. Tried it again tonight, now it does not.
libbindgen
C header:
void f(const int a[]);
I run:
$ bindgen const_array.h
I expect:
/* automatically generated by rust-bindgen */ extern "C" { pub fn f(a: *const ::std::os::raw::c_int); }
I get:
/* automatically generated by rust-bindgen */ extern "C" { pub fn f(a: *mut ::std::os::raw::c_int); }
Debug log:
INFO:bindgen: Clang Version: clang version 3.9.1 (tags/RELEASE_391/final) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [] }) }, declaration: None, loc: None DEBUG:bindgen::ir::function: Function::parse(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f")), Type(void (const int *), kind: FunctionProto, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (const int *), kind: FunctionProto, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void (const int *), kind: FunctionProto, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(1), ty: Type(void (const int *), kind: FunctionProto, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f"))) DEBUG:bindgen::ir::ty: currently_parsed_types: [] DEBUG:bindgen::ir::function: FunctionSig::from_ty Type(void (const int *), kind: FunctionProto, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)) Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f")) DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(2) Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::item: New unresolved type reference: Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: UnresolvedTypeRef(Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None), is_const: false }) }, declaration: Some(Cursor( kind: InvalidFile, loc: builtin definitions, usr: None)), loc: None DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: InvalidFile, loc: builtin definitions, usr: None) found for type Type { name: None, layout: None, kind: UnresolvedTypeRef(Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None), is_const: false } DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(3) Type(void, kind: Void, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), None, None DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void, kind: Void, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), None, None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }) } DEBUG:bindgen::ir::item: ItemId(4) already resolved: None DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(4), argument_types: [(Some("a"), ItemId(2))], is_variadic: false, abi: C }), is_const: false }) }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f"))) DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(4), argument_types: [(Some("a"), ItemId(2))], is_variadic: false, abi: C }), is_const: false } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Function(Function { name: "f", mangled_name: None, signature: ItemId(1), comment: None }) }, declaration: Some(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f"))), loc: Some(Cursor(f kind: FunctionDecl, loc: const_array.h:1:6, usr: Some("c:@F@f"))) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(6), ty: Type(const int [], kind: IncompleteArray, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))) DEBUG:bindgen::ir::ty: currently_parsed_types: [] DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const int, kind: Int, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("const int"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Int(Int), is_const: true }) } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Array(ItemId(8), 0), is_const: false }) }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(a kind: ParmDecl, loc: const_array.h:1:18, usr: Some("c:const_array.h@7@F@f@a"))) DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: None, kind: Array(ItemId(8), 0), is_const: false } DEBUG:bindgen::ir::context: No replacements to process DEBUG:bindgen::codegen: codegen: BindgenOptions { hidden_types: RegexSet { items: [], set: Some(RegexSet([])) }, opaque_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_functions: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_vars: RegexSet { items: [], set: Some(RegexSet([])) }, bitfield_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enums: RegexSet { items: [], set: Some(RegexSet([])) }, builtins: false, links: [], emit_ast: false, emit_ir: false, enable_cxx_namespaces: false, disable_name_namespacing: false, derive_debug: true, unstable_rust: true, use_core: false, ctypes_prefix: None, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], clang_args: ["-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1", "-isystem", "/usr/local/include", "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include", "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", "-isystem", "/usr/include", "-isystem", "/System/Library/Frameworks", "-isystem", "/Library/Frameworks", "const_array.h"], input_header: Some("const_array.h"), dummy_uses: None, type_chooser: None, codegen_config: CodegenConfig { functions: true, types: true, vars: true, methods: true, constructors: true }, conservative_inline_namespaces: false, generate_comments: true, whitelist_recursively: true, objc_extern_crate: false } DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [ItemId(2), ItemId(1), ItemId(5), ItemId(6)] }) } DEBUG:bindgen::codegen: <Module as CodeGenerator>::codegen: item = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [ItemId(2), ItemId(1), ItemId(5), ItemId(6)] }) } DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: ResolvedTypeRef(ItemId(6)), is_const: false }) } DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: ResolvedTypeRef(ItemId(6)), is_const: false }) } DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(4), argument_types: [(Some("a"), ItemId(2))], is_variadic: false, abi: C }), is_const: false }) } DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(4), argument_types: [(Some("a"), ItemId(2))], is_variadic: false, abi: C }), is_const: false }) } DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Function(Function { name: "f", mangled_name: None, signature: ItemId(1), comment: None }) } DEBUG:bindgen::codegen: <Function as CodeGenerator>::codegen: item = Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Function(Function { name: "f", mangled_name: None, signature: ItemId(1), comment: None }) } DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Array(ItemId(8), 0), is_const: false }) } DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Array(ItemId(8), 0), is_const: false }) }
The text was updated successfully, but these errors were encountered:
Thanks for the bug report!
Sorry, something went wrong.
Use the constness of the inner type when converting array function ar…
49468a0
…guments. Fixes rust-lang#509 I'm actually surprised we had no tests for this. Signed-off-by: Emilio Cobos Álvarez <[email protected]>
codegen: Use the constness of the inner type when converting array fu…
af6d59c
…nction arguments. Fixes rust-lang#509 I'm actually surprised we had no tests for this. Signed-off-by: Emilio Cobos Álvarez <[email protected]>
Auto merge of #513 - emilio:const-fn-arg, r=fitzgen
f1caa10
Use the constness of the inner type when converting array function args. Fixes #509 I'm actually surprised we had no tests for this.
No branches or pull requests
This used to work with
libbindgen
0.1.7. Tried it again tonight, now it does not.C header:
I run:
I expect:
I get:
Debug log:
The text was updated successfully, but these errors were encountered: