Skip to content

Commit a6e89bb

Browse files
committed
Use a named rather than anon struct in instance
The anonymous struct nested in a union triggers a -Wnested-anon-type warning ("anonymous types declared in an anonymous union are an extension") under clang (pybind#1204). This names the struct and defines it out of the definition of `instance` to get around to warning (and makes the code slightly simpler).
1 parent e119195 commit a6e89bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/pybind11/detail/common.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,18 @@ constexpr size_t instance_simple_holder_in_ptrs() {
377377
struct type_info;
378378
struct value_and_holder;
379379

380+
struct nonsimple_values_and_holders {
381+
void **values_and_holders;
382+
uint8_t *status;
383+
};
384+
380385
/// The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
381386
struct instance {
382387
PyObject_HEAD
383388
/// Storage for pointers and holder; see simple_layout, below, for a description
384389
union {
385390
void *simple_value_holder[1 + instance_simple_holder_in_ptrs()];
386-
struct {
387-
void **values_and_holders;
388-
uint8_t *status;
389-
} nonsimple;
391+
nonsimple_values_and_holders nonsimple;
390392
};
391393
/// Weak references (needed for keep alive):
392394
PyObject *weakrefs;

0 commit comments

Comments
 (0)