Skip to content

Commit 78aaa32

Browse files
committed
Added test for forward declared complex types
1 parent 8eb9e3f commit 78aaa32

File tree

2 files changed

+66
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)