Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual Destructors #1304

Open
BabaBert opened this issue Jan 9, 2024 · 1 comment
Open

Virtual Destructors #1304

BabaBert opened this issue Jan 9, 2024 · 1 comment

Comments

@BabaBert
Copy link

BabaBert commented Jan 9, 2024

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:                  ^          
@BabaBert
Copy link
Author

I suppose you have to wrap everything that is not directly supported by cxx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant