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

Re: [PATCH] Fix Solaris Workshop Compiler issues

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Nov 15, 2007, 00:44 UTC
Message-ID
<20071115004404.GB25021@atjola.homenet>
In-Reply-To
<7v3av89wq7.fsf@gitster.siamese.dyndns.org>
On 2007.11.14 16:30:08 -0800, Junio C Hamano wrote:
Show 46 quoted lines
> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
> 
> > No, just tried with cc: Sun C 5.7 Patch 117837-06 2005/10/05
> >
> > It's the "struct hack", ie. the incomplete array at the end of
> > delta_index. Still looking for a fix/workaround.
> 
> Do you mean the "FLEX_ARRAY" thing?
> 
> You can ask for FLEX_ARRAY from the command line of your "make"
> process.
> 
> There is this thing in git-compat-util.h
> 
>         #ifndef FLEX_ARRAY
>         #if defined(__GNUC__) && (__GNUC__ < 3)
>         #define FLEX_ARRAY 0
>         #else
>         #define FLEX_ARRAY /* empty */
>         #endif
>         #endif
> 
> The sources are written this way:
> 
> 	struct foo {
>         	... other members ...
>                 char last_member_that_is_flexible[FLEX_ARRAY];
> 	};
> 
> For older gcc, because we know about its lack of support, the
> above turns into:
> 
> 	struct foo {
>         	... other members ...
>                 char last_member_that_is_flexible[0];
>         }
> 
> But for recent enough compilers that grok the "flexible array
> members", the above expands to:
> 
> 	struct foo {
>         	... other members ...
>                 char last_member_that_is_flexible[];
>         }
> 
> Maybe your compiler needs -DFLEX_ARRAY=0 in CFLAGS?

Actually, I just created a test-case remotely on a Solaris box in my university (see below) and didn't compile the actual git code. With the FAM, cc complains about a redeclared identifier, with a zero-sized array, it complains that an array cannot be zero-sized...

Seems to be a known bug in Sun Studio 10: http://forum.java.sun.com/thread.jspa?threadID=5071896&messageID=9263771

Björn
#include <stdio.h>

struct foo; void bar(const struct foo *, unsigned long);

struct bla {
	unsigned long foo;
};
struct foo {
	unsigned long val;
	struct bla *blas[];
};
void bar(const struct foo *foo, unsigned long val)
{
	printf("%lu %lu\n", foo->val, val);
}
int main()
{
	struct foo foo;
	foo.val = 10;
	bar(&foo, 20);
	return 0;
}
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 31 in “Fix Solaris Workshop Compiler issues”
  1. Fix Solaris Workshop Compiler issuesGuido Ostkamp, Nov 14, 2007
  2. Alex RiesenNov 14, 2007
  3. Junio C HamanoNov 14, 2007
  4. Guido OstkampNov 14, 2007
  5. Alex RiesenNov 14, 2007
  6. Björn SteinbrinkNov 15, 2007
  7. Junio C HamanoNov 15, 2007
  8. Björn SteinbrinkNov 15, 2007
  9. Junio C HamanoNov 15, 2007
  10. Björn SteinbrinkNov 15, 2007
  11. Fix "identifier redeclared" compilation error with SUN cc.Björn Steinbrink, Nov 15, 2007
  12. Guido OstkampNov 15, 2007
  13. Junio C HamanoNov 15, 2007
  14. Guido OstkampNov 15, 2007
  15. Add mkdtemp() workaround for Sun Solaris 10Guido Ostkamp, Nov 16, 2007
  16. [RFH] Solaris portabilityJunio C Hamano, Nov 17, 2007
  17. Guido OstkampNov 18, 2007
  18. Junio C HamanoNov 18, 2007
  19. Junio C HamanoNov 16, 2007
  20. Björn SteinbrinkNov 16, 2007
  21. Fix "identifier redeclared" compilation error with SUN ccGuido Ostkamp, Nov 19, 2007
  22. Junio C HamanoNov 20, 2007
  23. Guido OstkampNov 20, 2007
  24. Guido OstkampNov 20, 2007
  25. Martin MaresNov 20, 2007
  26. Junio C HamanoNov 20, 2007
  27. Martin MaresNov 20, 2007
  28. Linus TorvaldsNov 15, 2007
  29. David KastrupNov 15, 2007
  30. Linus TorvaldsNov 15, 2007
  31. Junio C HamanoNov 15, 2007

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.