From: Brandon Casey Date: Mon, 8 Jun 2009 23:53:48 +0000 (-0500) Subject: git-compat-util.h: avoid using c99 flex array feature with Sun compiler 5.8 X-Git-Tag: v1.6.4-rc0~66^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=203ee91fd273ae424deeeee5ddcc7947a4c76ccd;p=git.git git-compat-util.h: avoid using c99 flex array feature with Sun compiler 5.8 The Sun c99 compiler as recent as version 5.8 Patch 121016-06 2007/08/01 produces an error when compiling diff-delta.c. This source file #includes the delta.h header file which pre-declares a struct which is later defined to contain a flex array member. The Sun c99 compiler fails to compile diff-delta.c and gives the following error: "diff-delta.c", line 314: identifier redeclared: create_delta current : function(pointer to const struct delta_index {unsigned long memsize, pointer to const void src_buf, unsigned long src_size, unsigned int hash_mask, array[-1] of pointer to struct index_entry {..} hash}, pointer to const void, unsigned long, pointer to unsigned long, unsigned long) returning pointer to void previous: function(pointer to const struct delta_index {unsigned long memsize, pointer to const void src_buf, unsigned long src_size, unsigned int hash_mask, array[-1] of pointer to struct index_entry {..} hash}, pointer to const void, unsigned long, pointer to unsigned long, unsigned long) returning pointer to void : "delta.h", line 44 c99: acomp failed for diff-delta.c So, avoid using this c99 feature when compiling with the Sun c compilers version 5.8 and older (the most recent version tested). Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- diff --git a/git-compat-util.h b/git-compat-util.h index 71197d977..48d99fab8 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -7,7 +7,7 @@ /* * See if our compiler is known to support flexible array members. */ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && (!defined(__SUNPRO_C) || (__SUNPRO_C > 0x580)) # define FLEX_ARRAY /* empty */ #elif defined(__GNUC__) # if (__GNUC__ >= 3)