mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
another attempt to fix the offsetof warnings
This commit is contained in:
parent
9dcb1c3b3a
commit
88d1d04132
@ -191,14 +191,18 @@ NAMESPACE_BEGIN(detail)
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -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 @@ protected:
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user