git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] git-compat-util.h: implement a different ARRAY_SIZE macro for for safely deriving the size of array

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 30, 2015, 17:59 UTC
Message-ID
<xmqq4mnx1or9.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqq8ud91ozm.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> ISTR that you compile with "-std=c89". typeof was added in c99, I think
>> (and was a GNU extension before that). I wonder if that is fooling the
>> gcc version-check.
>
> Yeah, I think that is very likely.

Yes. One workaround is to explicitly say that we accept the GNU extension in the source, perhaps.

 git-compat-util.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index f1f8f23..7fad5aa 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -62,8 +62,8 @@
 # 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])))
+	BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(__typeof__(arr), \
+							   __typeof__(&(arr)[0])))
 # else
 #  define BARF_UNLESS_AN_ARRAY(arr) 0
 # endif
Previous: Junio C HamanoNext: Jeff King
Message 6 of 7 in “git-compat-util.h: implement a different ARRAY_SIZE macro for for safely deriving the size of array”
  1. git-compat-util.h: implement a different ARRAY_SIZE macro for for safely deriving the size of arrayElia Pinto, Apr 30, 2015
  2. Junio C HamanoApr 30, 2015
  3. Junio C HamanoApr 30, 2015
  4. Jeff KingApr 30, 2015
  5. Junio C HamanoApr 30, 2015
  6. Junio C HamanoApr 30, 2015
  7. Jeff KingApr 30, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.