diff --git a/database/database.h.in b/database/database.h.in index bfa910b6..aa77de8a 100644 --- a/database/database.h.in +++ b/database/database.h.in @@ -735,10 +735,10 @@ typedef struct int prop_len; /* String length or number of values */ union { Plane *prop_plane; /* For PROPERTY_TYPE_PLANE */ - int prop_integer[]; /* For PROPERTY_TYPE_INTEGER or _DIMENSION */ - dlong prop_double[]; /* For PROPERTY_TYPE_DOUBLE */ - char prop_string[]; /* For PROPERTY_TYPE_STRING, must be last in - * struct and union */ + FLEX_UNION_MEMBER(int prop_integer[], 0); /* For PROPERTY_TYPE_INTEGER or _DIMENSION */ + FLEX_UNION_MEMBER(dlong prop_double[], 1); /* For PROPERTY_TYPE_DOUBLE */ + FLEX_UNION_MEMBER(char prop_string[], 2); /* For PROPERTY_TYPE_STRING, must be last in + * struct and union */ } prop_value; } PropertyRecord; diff --git a/utils/hash.h b/utils/hash.h index 1fb25ee4..d7ddc3fe 100644 --- a/utils/hash.h +++ b/utils/hash.h @@ -34,10 +34,10 @@ typedef struct h1 char *h_pointer; /* Pointer to anything. */ struct h1 *h_next; /* Next element, zero for end. */ union { - const char *h_ptr; /* One-word key value to identify entry. */ - /* Following members must be the last part of the struct and union:*/ - unsigned h_words[]; /* N-word key value. */ - char h_name[]; /* Text name of this entry. */ + const char *h_ptr; /* One-word key value to identify entry. */ + /* Following members must be the last part of the struct and union:*/ + FLEX_UNION_MEMBER(unsigned h_words[], 0); /* N-word key value. */ + FLEX_UNION_MEMBER(char h_name[], 1); /* Text name of this entry. */ } h_key; } HashEntry; diff --git a/utils/magic.h b/utils/magic.h index ded4bf1c..cd9a9b18 100644 --- a/utils/magic.h +++ b/utils/magic.h @@ -286,6 +286,19 @@ extern char AbortMessage[]; #endif #endif + +/* + * In GCC <= 14, flexible arrays are not supported in unions because of a parser + * limitation. + * + * This is a hack that declares an anonymous struct, which itself can contain + * a flexible array but still be a member of a union. Another empty element is + * included because structs that only contain a flexible array are also invalid. + */ +#define FLEX_UNION_MEMBER(member, member_no) struct {\ + char __empty ## member_no [0]; member;\ +} + /* ------------------ End of Machine Configuration Section ----------------- */ #endif /* _MAGIC__UTILS__MAGIC_H */