diff --git a/gcc-test/build.rs b/gcc-test/build.rs index 95291bc..3256b0a 100644 --- a/gcc-test/build.rs +++ b/gcc-test/build.rs @@ -13,11 +13,6 @@ fn main() { .include("src/include") .compile("libbar.a"); - gcc::Config::new() - .file("src/bar1.c") - .file("src/bar2.c") - .compile("libbar.a"); - let target = std::env::var("TARGET").unwrap(); let file = target.split("-").next().unwrap(); let file = format!("src/{}.{}", file, @@ -25,4 +20,9 @@ fn main() { gcc::Config::new() .file(file) .compile("libasm.a"); + + gcc::Config::new() + .file("src/baz.cpp") + .cpp(true) + .compile("libbaz.a"); } diff --git a/gcc-test/src/baz.cpp b/gcc-test/src/baz.cpp new file mode 100644 index 0000000..2d4b959 --- /dev/null +++ b/gcc-test/src/baz.cpp @@ -0,0 +1,9 @@ +#include + +extern "C" int32_t +baz() { + int *a = new int(8); + int b = *a; + delete a; + return b; +} diff --git a/gcc-test/src/lib.rs b/gcc-test/src/lib.rs index 0e992db..77ab479 100644 --- a/gcc-test/src/lib.rs +++ b/gcc-test/src/lib.rs @@ -5,4 +5,6 @@ extern { pub fn bar2() -> i32; pub fn asm() -> i32; + + pub fn baz() -> i32; } diff --git a/gcc-test/tests/all.rs b/gcc-test/tests/all.rs index ca24ba8..009ba9c 100644 --- a/gcc-test/tests/all.rs +++ b/gcc-test/tests/all.rs @@ -17,10 +17,16 @@ fn bar_here() { } } - #[test] fn asm_here() { unsafe { assert_eq!(asm(), 7); } } + +#[test] +fn baz_here() { + unsafe { + assert_eq!(baz(), 8); + } +}