fix: suppress -Wredundant-decls for class.h declarations Several functions are forward-declared in headers that cannot include class.h; GCC's -Wredundant-decls (used in CI cxx_flags) flags the second declaration. Assisted-by: ClaudeCode:claude-fable-5
diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index 2ecde4f..74e5ef0 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h
@@ -27,6 +27,12 @@ setattr((PyObject *) obj, "__qualname__", nameobj) #endif +PYBIND11_WARNING_PUSH +// Several of these functions are forward-declared in other headers (internals.h, +// type_caster_base.h, trampoline_self_life_support.h, cpp_conduit.h), which cannot +// include this file; the declarations here are the canonical set. +PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls") + std::string get_fully_qualified_tp_name(PyTypeObject *type); PyTypeObject *type_incref(PyTypeObject *type); @@ -124,13 +130,8 @@ /// to destroy the C++ object itself, while the rest is Python bookkeeping. extern "C" void pybind11_object_dealloc(PyObject *self); -PYBIND11_WARNING_PUSH -PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls") - std::string error_string(); -PYBIND11_WARNING_POP - /** Create the type which can be used as a common base for all classes. This is needed in order to satisfy Python's requirements for multiple inheritance. Return value: New reference. */ @@ -158,6 +159,8 @@ Return value: New reference. */ PyObject *make_new_python_type(const type_record &rec); +PYBIND11_WARNING_POP + PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)