Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'cb/array-size'
* cb/array-size:
  Fix definition of ARRAY_SIZE for non-gcc builds
  • Loading branch information
Junio C Hamano committed Jun 25, 2015
2 parents a6a1ad9 + e2c6f7c commit 5416f8a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions git-compat-util.h
Expand Up @@ -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
Expand Down

0 comments on commit 5416f8a

Please sign in to comment.