Skip to content

Commit 21d6a6b

Browse files
committed
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
1 parent f8e4106 commit 21d6a6b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎include/pybind11/detail/class.h‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ PYBIND11_NAMESPACE_BEGIN(detail)
2727
setattr((PyObject *) obj, "__qualname__", nameobj)
2828
#endif
2929

30+
PYBIND11_WARNING_PUSH
31+
// Several of these functions are forward-declared in other headers (internals.h,
32+
// type_caster_base.h, trampoline_self_life_support.h, cpp_conduit.h), which cannot
33+
// include this file; the declarations here are the canonical set.
34+
PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls")
35+
3036
std::string get_fully_qualified_tp_name(PyTypeObject *type);
3137

3238
PyTypeObject *type_incref(PyTypeObject *type);
@@ -124,13 +130,8 @@ void clear_instance(PyObject *self);
124130
/// to destroy the C++ object itself, while the rest is Python bookkeeping.
125131
extern "C" void pybind11_object_dealloc(PyObject *self);
126132

127-
PYBIND11_WARNING_PUSH
128-
PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls")
129-
130133
std::string error_string();
131134

132-
PYBIND11_WARNING_POP
133-
134135
/** Create the type which can be used as a common base for all classes. This is
135136
needed in order to satisfy Python's requirements for multiple inheritance.
136137
Return value: New reference. */
@@ -158,6 +159,8 @@ void enable_buffer_protocol(PyHeapTypeObject *heap_type);
158159
Return value: New reference. */
159160
PyObject *make_new_python_type(const type_record &rec);
160161

162+
PYBIND11_WARNING_POP
163+
161164
PYBIND11_NAMESPACE_END(detail)
162165
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
163166

0 commit comments

Comments
 (0)