another attempt to fix the offsetof warnings
diff --git a/include/pybind11/common.h b/include/pybind11/common.h
index 7122d80..a63b7f5 100644
--- a/include/pybind11/common.h
+++ b/include/pybind11/common.h
@@ -191,14 +191,18 @@
inline std::string error_string();
-/// PyObject wrapper around generic types
-template <typename type, typename holder_type = std::unique_ptr<type>> struct instance {
+/// Core part of the 'instance' type which POD (needed to be able to use 'offsetof')
+template <typename type> struct instance_essentials {
PyObject_HEAD
type *value;
PyObject *parent;
PyObject *weakrefs;
bool owned : 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;
};
diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h
index 25e25ca..bbcda47 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -22,9 +22,6 @@
# pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
-# if __GNUC__ >= 4
-# pragma GCC diagnostic ignored "-Wno-invalid-offsetof"
-# endif
#endif
#include "attr.h"
@@ -566,7 +563,7 @@
type->ht_type.tp_dealloc = rec->dealloc;
/* 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 */
type->ht_type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;