Skip to content

Commit

Permalink
Added test for forward declared complex types
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilshagri committed Jan 26, 2017
1 parent 1a56a6a commit 9866229
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/expectations/tests/forward_declared_complex_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]


#[repr(C)]
pub struct Foo([u8; 0]);
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Bar {
pub f: *mut Foo,
}
#[test]
fn bindgen_test_layout_Bar() {
assert_eq!(::std::mem::size_of::<Bar>() , 8usize);
assert_eq!(::std::mem::align_of::<Bar>() , 8usize);
}
impl Clone for Bar {
fn clone(&self) -> Self { *self }
}
extern "C" {
#[link_name = "_Z10baz_structP3Foo"]
pub fn baz_struct(f: *mut Foo);
}
#[repr(C)]
pub struct Union([u8; 0]);
extern "C" {
#[link_name = "_Z9baz_unionP5Union"]
pub fn baz_union(u: *mut Union);
}
#[repr(C)]
pub struct Quux([u8; 0]);
extern "C" {
#[link_name = "_Z9baz_classP4Quux"]
pub fn baz_class(q: *mut Quux);
}
15 changes: 15 additions & 0 deletions tests/headers/forward_declared_complex_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct Foo;

struct Bar {
Foo *f;
};

void baz_struct(Foo* f);

union Union;

void baz_union(Union* u);

class Quux;

void baz_class(Quux* q);

0 comments on commit 9866229

Please sign in to comment.