FLEX_ARRAY: require platforms to support the C99 syntax

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>

Junio C Hamano committed Dec 12, 2025 at 21:54 UTC 4d75f2aea776f434b51481ae65233d6012da1a66
1 file changed +2 -31
git-compat-util.h
+2 -31
@@ -38,37 +38,8 @@ struct strbuf;
38 DISABLE_WARNING(-Wsign-compare)
39 #endif
40
41 -#ifndef FLEX_ARRAY
42 -/*
43 - * See if our compiler is known to support flexible array members.
44 - */
45 -
46 -/*
47 - * Check vendor specific quirks first, before checking the
48 - * __STDC_VERSION__, as vendor compilers can lie and we need to be
49 - * able to work them around. Note that by not defining FLEX_ARRAY
50 - * here, we can fall back to use the "safer but a bit wasteful" one
51 - * later.
52 - */
53 -#if defined(__SUNPRO_C) && (__SUNPRO_C <= 0x580)
54 -#elif defined(__GNUC__)
55 -# if (__GNUC__ >= 3)
56 -# define FLEX_ARRAY /* empty */
57 -# else
58 -# define FLEX_ARRAY 0 /* older GNU extension */
59 -# endif
60 -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
61 -# define FLEX_ARRAY /* empty */
62 -#endif
63 -
64 -/*
65 - * Otherwise, default to safer but a bit wasteful traditional style
66 - */
67 -#ifndef FLEX_ARRAY
68 -# define FLEX_ARRAY 1
69 -#endif
70 -#endif
71 -
41 +#undef FLEX_ARRAY
42 +#define FLEX_ARRAY /* empty - weather balloon to require C99 FAM */
43
44 /*
45 * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.