]> git.ipfire.org Git - thirdparty/git.git/commitdiff
FLEX_ARRAY: require platforms to support the C99 syntax
authorJunio C Hamano <gitster@pobox.com>
Fri, 12 Dec 2025 12:54:14 +0000 (21:54 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Dec 2025 13:05:19 +0000 (22:05 +0900)
Before C99 syntax to express that the final member in a struct is an
array of unknown number of elements, i.e.,

struct {
...
T flexible_array[];
};

came along, GNU introduced their own extension to declare such a
member with 0 size, i.e.,

T flexible_array[0];

and the compilers that did not understand even that were given a way
to emulate it by wasting one element, i.e.,

T flexible_array[1];

As we are using more and more C99 language features, let's see if
the platforms that still need to resort to the historical forms of
flexible array member support are still there, by forcing all the
flex array definitions to use the C99 syntax and see if anybody
screams (in which case reverting the changes is rather easy).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h

index 398e0fac4fab6007903fdd9fd31dcc28fe531a65..8010397bdb5b805f3374b1797fceb01e0b1271b9 100644 (file)
@@ -38,37 +38,8 @@ struct strbuf;
 DISABLE_WARNING(-Wsign-compare)
 #endif
 
-#ifndef FLEX_ARRAY
-/*
- * See if our compiler is known to support flexible array members.
- */
-
-/*
- * Check vendor specific quirks first, before checking the
- * __STDC_VERSION__, as vendor compilers can lie and we need to be
- * able to work them around.  Note that by not defining FLEX_ARRAY
- * here, we can fall back to use the "safer but a bit wasteful" one
- * later.
- */
-#if defined(__SUNPRO_C) && (__SUNPRO_C <= 0x580)
-#elif defined(__GNUC__)
-# if (__GNUC__ >= 3)
-#  define FLEX_ARRAY /* empty */
-# else
-#  define FLEX_ARRAY 0 /* older GNU extension */
-# endif
-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-# define FLEX_ARRAY /* empty */
-#endif
-
-/*
- * Otherwise, default to safer but a bit wasteful traditional style
- */
-#ifndef FLEX_ARRAY
-# define FLEX_ARRAY 1
-#endif
-#endif
-
+#undef FLEX_ARRAY
+#define FLEX_ARRAY /* empty - weather balloon to require C99 FAM */
 
 /*
  * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.