Skip to content

Instantly share code, notes, and snippets.

@andyjsbell
Created July 16, 2020 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyjsbell/52420f55cda31ef7dd7547c3ec2e1183 to your computer and use it in GitHub Desktop.
Save andyjsbell/52420f55cda31ef7dd7547c3ec2e1183 to your computer and use it in GitHub Desktop.
use cpp::cpp;
use cpp::cpp_class;
cpp!{{
#include <iostream>
using std::string;
class Test {
public:
Test() {
std::cout << "creating" << std::endl;
}
virtual ~Test() {
std::cout << "destroying" << std::endl;
}
protected:
std::string message; // -> removing this and we don't get the issue
};
}}
cpp_class!(pub unsafe struct Test as "Test");
impl Test {
fn new() -> Self {
unsafe { cpp!([] -> Test as "Test" { return Test(); }) }
}
}
fn main() {
let test = Test::new();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment