I'm trying to following the example here:
#include <string>
#include <emscripten/bind.h>
using namespace emscripten;
struct Interface {
virtual void invoke(const std::string& str) = 0;
};
struct InterfaceWrapper : public wrapper<Interface> {
EMSCRIPTEN_WRAPPER(InterfaceWrapper);
void invoke(const std::string& str) {
return call<void>("invoke", str);
}
};
EMSCRIPTEN_BINDINGS(interface) {
class_<Interface>("Interface")
.function("invoke", &Interface::invoke, pure_virtual())
.allow_subclass<InterfaceWrapper>("InterfaceWrapper")
;
}
and em++ is giving me this warning:
moche01@gunbuster:~/sandbox/emscripten-play$ em++ -Wall --bind interface.cppIn file included from interface.cpp:2:
/Users/moche01/sandbox/emscripten-play/emsdk/fastcomp/emscripten/system/include/emscripten/bind.h:459:13: warning: delete called on 'Interface' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
delete ptr;
^
/Users/moche01/sandbox/emscripten-play/emsdk/fastcomp/emscripten/system/include/emscripten/bind.h:1276:32: note: in instantiation of function template specialization 'emscripten::internal::raw_destructor<Interface>'
requested here
auto destructor = &raw_destructor<ClassType>;
^
interface.cpp:18:5: note: in instantiation of member function 'emscripten::class_<Interface, emscripten::internal::NoBaseClass>::class_' requested here
class_<Interface>("Interface")
^
In file included from interface.cpp:2:
/Users/moche01/sandbox/emscripten-play/emsdk/fastcomp/emscripten/system/include/emscripten/bind.h:459:13: warning: delete called on non-final 'InterfaceWrapper' that has virtual functions but non-virtual destructor
[-Wdelete-non-virtual-dtor]
delete ptr;
^
/Users/moche01/sandbox/emscripten-play/emsdk/fastcomp/emscripten/system/include/emscripten/bind.h:1276:32: note: in instantiation of function template specialization 'emscripten::internal::raw_destructor<InterfaceWrapper>'
requested here
auto destructor = &raw_destructor<ClassType>;
^
/Users/moche01/sandbox/emscripten-play/emsdk/fastcomp/emscripten/system/include/emscripten/bind.h:1373:24: note: in instantiation of member function 'emscripten::class_<InterfaceWrapper, emscripten::base<Interface>
>::class_' requested here
auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName)
^
interface.cpp:20:10: note: in instantiation of function template specialization 'emscripten::class_<Interface, emscripten::internal::NoBaseClass>::allow_subclass<InterfaceWrapper>' requested here
.allow_subclass<InterfaceWrapper>("InterfaceWrapper")
^
2 warnings generated.
I understand this is saying that Interface doesn't have a virtual destructor. My question is: why is embind trying to call 'delete' on the interface? In the case where I don't have control over the source code of the Interface class, can I wrap the interface in a way that doesn't produce this warning?
Thanks,
Mo