summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2022-01-05 14:01:27 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-01-05 14:01:27 -0800
commitd0c99fcc618fc71cff261246b9d5605cbd225329 (patch)
tree61295f695dca93020a94fab984c546cff91f1d3d
parentMerge branch 'jh/p4-rcs-expansion-in-bytestring' (diff)
parentflex-array: simplify compiler-specific workaround (diff)
downloadtgif-d0c99fcc618fc71cff261246b9d5605cbd225329.tar.xz
Merge branch 'jc/flex-array-definition'
The conditions to choose different definitions of the FLEX_ARRAY macro for vendor compilers has been simplified to make it easier to maintain. * jc/flex-array-definition: flex-array: simplify compiler-specific workaround
-rw-r--r--git-compat-util.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 5fa54a7afe..b7caf23666 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -46,14 +46,23 @@
/*
* See if our compiler is known to support flexible array members.
*/
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && (!defined(__SUNPRO_C) || (__SUNPRO_C > 0x580))
-# define FLEX_ARRAY /* empty */
+
+/*
+ * 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
/*