Re: [PATCH] Fix Solaris Workshop Compiler issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2007.11.14 16:30:08 -0800, Junio C Hamano wrote:
> Björn Steinbrink <B.Steinbrink@xxxxxx> 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;
}

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux