Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15
DORMANTno replies

[PATCH] Fix "identifier redeclared" compilation error with SUN cc

From: Guido Ostkamp <hidden>
Date: 2016-06-15 22:43:52
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Hello Junio,

On Thu, 15 Nov 2007, Junio C Hamano wrote:
As I suspect there are other compilers that do not implement flexible 
array members (so you cannot use "member[]") nor older gcc extension of 
zero sized member (so you cannot use "member[0]" either), this checking 
specifically for Sun is too narrow.

On the other hand, as you said, this is too broad, because not everybody 
may be using the SUN compiler on Sun, nor the version that does not 
understand flexible array members.

But being broad should always be safer, albeit a bit wasteful.

How about doing it this way?
it looks ok on Solaris. I assembled the following patch from your posting, 
could you please include it?


Signed-off-by: Guido Ostkamp <redacted>
---
  git-compat-util.h |   11 ++++++++++-
  1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 276a437..97759fd 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -4,11 +4,20 @@
  #define _FILE_OFFSET_BITS 64

  #ifndef FLEX_ARRAY
-#if defined(__GNUC__) && (__GNUC__ < 3)
+#if defined(__GNUC__)
+#if (__GNUC__ < 3)
  #define FLEX_ARRAY 0
  #else
  #define FLEX_ARRAY /* empty */
  #endif
+#else
+/* more cases we know we can use 0 or empty can come here */
+#endif
+#endif
+
+/* if still undefined, default to the safe, old fashioned way */
+#ifndef FLEX_ARRAY
+#define FLEX_ARRAY 1
  #endif

  #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-- 
1.5.3.6.728.gea559
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help