Commit 88d1d041 authored by Wenzel Jakob's avatar Wenzel Jakob
Browse files

another attempt to fix the offsetof warnings

parent 9dcb1c3b
...@@ -191,14 +191,18 @@ NAMESPACE_BEGIN(detail) ...@@ -191,14 +191,18 @@ NAMESPACE_BEGIN(detail)
inline std::string error_string(); inline std::string error_string();
/// PyObject wrapper around generic types /// Core part of the 'instance' type which POD (needed to be able to use 'offsetof')
template <typename type, typename holder_type = std::unique_ptr<type>> struct instance { template <typename type> struct instance_essentials {
PyObject_HEAD PyObject_HEAD
type *value; type *value;
PyObject *parent; PyObject *parent;
PyObject *weakrefs; PyObject *weakrefs;
bool owned : 1; bool owned : 1;
bool constructed : 1; bool constructed : 1;
};
/// PyObject wrapper around generic types, includes a special holder type that is responsible for lifetime management
template <typename type, typename holder_type = std::unique_ptr<type>> struct instance : instance_essentials<type> {
holder_type holder; holder_type holder;
}; };
......
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
# pragma GCC diagnostic ignored "-Wunused-but-set-parameter" # pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
# pragma GCC diagnostic ignored "-Wunused-but-set-variable" # pragma GCC diagnostic ignored "-Wunused-but-set-variable"
# pragma GCC diagnostic ignored "-Wmissing-field-initializers" # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
# if __GNUC__ >= 4
# pragma GCC diagnostic ignored "-Wno-invalid-offsetof"
# endif
#endif #endif
#include "attr.h" #include "attr.h"
...@@ -566,7 +563,7 @@ protected: ...@@ -566,7 +563,7 @@ protected:
type->ht_type.tp_dealloc = rec->dealloc; type->ht_type.tp_dealloc = rec->dealloc;
/* Support weak references (needed for the keep_alive feature) */ /* Support weak references (needed for the keep_alive feature) */
type->ht_type.tp_weaklistoffset = offsetof(instance<void>, weakrefs); type->ht_type.tp_weaklistoffset = offsetof(instance_essentials<void>, weakrefs);
/* Flags */ /* Flags */
type->ht_type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE; type->ht_type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment