Hi,
this isn't an embind issue - c++ compiler requires that abstract classes
implement a virtual destructor.
https://stackoverflow.com/questions/8764353/what-does-has-virtual-method-but-non-virtual-destructor-warning-mean-durin

On Wed, 7 Aug 2019 at 00:16, Mo Chen <[email protected]> wrote:

> I'm trying to following the example here:
>
>
> https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#deriving-from-c-classes-in-javascript
>
> #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.cpp
> 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 '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
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/e29ed773-dd48-4e22-a739-77598a150fd2%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/e29ed773-dd48-4e22-a739-77598a150fd2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGYzdYpJVWqTdtDRBejPrMDUG%2BkA3J%3DdT0iSSQUP2Hovqg%40mail.gmail.com.

Reply via email to