summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorCharles Bailey <cbailey32@bloomberg.net>2015-06-24 22:12:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-25 00:14:00 (GMT)
commite2c6f7cd5a66ed0009662d2651e0cf3c655e83a9 (patch)
treec79b499b4fe40cb26c4d8b78e920f6e60b709432 /git-compat-util.h
parent89c855ed3cbe64bea93ea081d0e96077e9ee8517 (diff)
downloadgit-e2c6f7cd5a66ed0009662d2651e0cf3c655e83a9.zip
git-e2c6f7cd5a66ed0009662d2651e0cf3c655e83a9.tar.gz
git-e2c6f7cd5a66ed0009662d2651e0cf3c655e83a9.tar.bz2
Fix definition of ARRAY_SIZE for non-gcc builds
The improved ARRAY_SIZE macro uses BARF_UNLESS_AN_ARRAY which expands to a valid check for recent gcc versions and to 0 for older gcc versions but is not defined on non-gcc builds. Non-gcc builds need this macro to expand to 0 as well. The current outer test (defined(__GNUC__) && (__GNUC__ >= 3)) is a strictly weaker condition than the inner test (GIT_GNUC_PREREQ(3, 1)) so we can omit the outer test and cause the BARF_UNLESS_AN_ARRAY macro to be defined correctly on non-gcc builds as well as gcc builds with older versions. Signed-off-by: Charles Bailey <cbailey32@bloomberg.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 7fad5aa..079b99d 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -58,15 +58,13 @@
#define BUILD_ASSERT_OR_ZERO(cond) \
(sizeof(char [1 - 2*!(cond)]) - 1)
-#if defined(__GNUC__) && (__GNUC__ >= 3)
-# if GIT_GNUC_PREREQ(3, 1)
+#if GIT_GNUC_PREREQ(3, 1)
/* &arr[0] degrades to a pointer: a different type from an array */
# define BARF_UNLESS_AN_ARRAY(arr) \
BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(__typeof__(arr), \
__typeof__(&(arr)[0])))
-# else
-# define BARF_UNLESS_AN_ARRAY(arr) 0
-# endif
+#else
+# define BARF_UNLESS_AN_ARRAY(arr) 0
#endif
/*
* ARRAY_SIZE - get the number of elements in a visible array