Skip to content

Commit 9866229

Browse files
committed
Added test for forward declared complex types
1 parent 1a56a6a commit 9866229

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
pub struct Foo([u8; 0]);
9+
#[repr(C)]
10+
#[derive(Debug, Copy)]
11+
pub struct Bar {
12+
pub f: *mut Foo,
13+
}
14+
#[test]
15+
fn bindgen_test_layout_Bar() {
16+
assert_eq!(::std::mem::size_of::<Bar>() , 8usize);
17+
assert_eq!(::std::mem::align_of::<Bar>() , 8usize);
18+
}
19+
impl Clone for Bar {
20+
fn clone(&self) -> Self { *self }
21+
}
22+
extern "C" {
23+
#[link_name = "_Z10baz_structP3Foo"]
24+
pub fn baz_struct(f: *mut Foo);
25+
}
26+
#[repr(C)]
27+
pub struct Union([u8; 0]);
28+
extern "C" {
29+
#[link_name = "_Z9baz_unionP5Union"]
30+
pub fn baz_union(u: *mut Union);
31+
}
32+
#[repr(C)]
33+
pub struct Quux([u8; 0]);
34+
extern "C" {
35+
#[link_name = "_Z9baz_classP4Quux"]
36+
pub fn baz_class(q: *mut Quux);
37+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct Foo;
2+
3+
struct Bar {
4+
Foo *f;
5+
};
6+
7+
void baz_struct(Foo* f);
8+
9+
union Union;
10+
11+
void baz_union(Union* u);
12+
13+
class Quux;
14+
15+
void baz_class(Quux* q);

0 commit comments

Comments
 (0)