Skip to content

Commit 17e2003

Browse files
committed
codegen: Use the canonical type to determine whether we should convert to a pointer an argument.
Fixes https://github.com/Yamakaky/rust-bindgen/issues/407
1 parent f7a328a commit 17e2003

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

libbindgen/src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ impl ToRustTy for FunctionSig {
19451945
// the array type derivation.
19461946
//
19471947
// [1]: http://c0x.coding-guidelines.com/6.7.5.3.html
1948-
let arg_ty = if let TypeKind::Array(t, _) = *arg_ty.kind() {
1948+
let arg_ty = if let TypeKind::Array(t, _) = *arg_ty.canonical_type(ctx).kind() {
19491949
t.to_rust_ty(ctx).to_ptr(arg_ty.is_const(), ctx.span())
19501950
} else {
19511951
arg_item.to_rust_ty(ctx)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
pub type myVector3 = [f32; 3usize];
8+
extern "C" {
9+
pub fn modifyVectorFunc(v: *mut f32);
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// foo.h
2+
typedef float myVector3[3];
3+
void modifyVectorFunc(myVector3 v);

0 commit comments

Comments
 (0)