pybind / pybind/pybind11

[smart_holder]: trampoline_self_life_support -fvisibility question

Open
#3,927 8 comments 0 reactions 1 assignee View on GitHub

@rwgk is already working on this.

Since May 9, 2022.

smart holder triage
Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Required prerequisites
Problem description

I'm attempting to use the Progressive mode to solve a lifetime issue with a trampoline class via the following steps:

  1. Added -DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT to compilation commands
  2. Replaced std::shared_ptr<...> holder with PYBIND11_SH_DEF(Foo)
  3. Inherit trampoline class from public py::trampoline_self_life_support

When I compile, I get this warning:

warning: ‘PyFoo’ declared with greater visibility than its base ‘pybind11::trampoline_self_life_support’ [-Wattributes]
  134 | class PyFoo : Foo, py::trampoline_self_life_support {
Reproducible example code
// C++
#include <pybind11/pybind11.h>

class Foo {
public:
	virtual ~Foo()                   = default;
};


// Trampoline class
class PyFoo : Foo, public py::trampoline_self_life_support {
public:
	using Foo::Foo;
};

// Bindings
PYBIND11_MODULE("smart_holder", m) {
	py::class_<Foo, PyFoo, PYBIND11_SH_DEF(Foo)>(m, "Foo")
		.def(py::init<>())
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.