Open BabaBert opened 6 months ago
I saw this mentioned here before, but there seems to be no recommended way of handling virtual destructors. I.e.:
struct SomeStruct { static std::unique_ptr<SomeStruct> open(const char* filePath); protected: virtual ~SomeStruct() {} }
The error output looks something like this:
... warning: /usr/include/c++/7/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = SomeStruct]’: warning: /usr/include/c++/7/bits/unique_ptr.h:263:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = SomeStruct; _Dp = std::default_delete<SomeStruct>]’ warning: .../cxxbridge.rs.cc:101:34: required from here warning: /usr/include/c++/7/bits/unique_ptr.h:78:2: error: ‘virtual SomeStruct::~SomeStruct()’ is protected within this context warning: delete __ptr; warning: ^~~~~~ warning: In file included from .../wrapper.hpp:2:0, warning: from .../cxxbridge.rs.cc:1: warning: something.hpp:40:17: note: declared protected here warning: virtual ~SomeStruct(); warning: ^
I suppose you have to wrap everything that is not directly supported by cxx?
I saw this mentioned here before, but there seems to be no recommended way of handling virtual destructors. I.e.:
The error output looks something like this: