#include class test { int key; public: test(int key) : key(key) { std::cout << "test ctor" << std::endl; } virtual ~test() { std::cout << "test dtor" << std::endl; } int compute(int x) { return key + x; } }; #include "cxx_wrapped.h" template<> char const* wrapped::ml_name() { return "test"; } extern "C" { CAMLprim value ml_test_create(value v_k) { CAMLparam1(v_k); test* p = new test(Int_val(v_k)); CAMLreturn(wrapped::alloc(p)); } CAMLprim value ml_test_compute(value v, value v_x) { CAMLparam2(v,v_x); CAMLreturn(Val_int(wrapped::get(v)->compute(Int_val(v_x)))); } CAMLprim value ml_test_destroy(value v) { CAMLparam1(v); wrapped::release(v); CAMLreturn(Val_unit); } } // extern "C"