Skip to content

Commit 4d75f2a

Browse files
committed
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>
1 parent e85ae27 commit 4d75f2a

1 file changed

Lines changed: 2 additions & 31 deletions

File tree

git-compat-util.h

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,8 @@ struct strbuf;
3838
DISABLE_WARNING(-Wsign-compare)
3939
#endif
4040

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 */
7243

7344
/*
7445
* BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.

0 commit comments

Comments
 (0)