Re: [PATCH v2 3/8] diff-delta.c: "delta.h" is not a required include
- From
Brandon Casey <drafnel@gmail.com>
- Date
- Jun 6, 2009, 03:56 UTC
- Message-ID
- <ee63ef30906052056le082bffrec078981dddaa013@mail.gmail.com>
- In-Reply-To
- <alpine.LFD.2.00.0906052302550.3906@xanadu.home>
On Fri, Jun 5, 2009 at 10:10 PM, Nicolas Pitre<nico@cam.org> wrote:
Show 57 quoted lines
> On Fri, 5 Jun 2009, Brandon Casey wrote:
>
>> Nicolas Pitre wrote:
>> > On Fri, 5 Jun 2009, Brandon Casey wrote:
>> >
>> >> From: Brandon Casey <drafnel@gmail.com>
>> >>
>> >> When compiling diff-delta.c with the SUNWspro C99 compiler, it complains
>> >>
>> >> "diff-delta.c", line 314: identifier redeclared: create_delta
>> >>
>> >> There is nothing in "delta.h" that is required by diff-delta.c, so don't
>> >> include it.
>> >>
>> >> Signed-off-by: Brandon Casey <drafnel@gmail.com>
>> >
>> > NAK.
>> >
>> > This is common practice to include the header file declaring function
>> > prototypes into the file defining the actual function so to make sure
>> > the declaration matches with the definition. Deleting that include is
>> > actively ignoring a problem instead of fixing the cause of it.
>>
>>
>> It doesn't seem to like the structure being redeclared with a flex array
>> member and being passed as a const argument.
>>
>>
>> # cat > test.c <<EOF
>>
>> struct a_struct;
>>
>> extern void *test_func(const struct a_struct *f);
>>
>> struct a_struct {
>> int a;
>> int b;
>> char* c[];
>> };
>>
>> void *test_func(const struct a_struct *f)
>> {
>> return 0;
>> }
>> EOF
>>
>> # /opt/SUNWspro/bin/c99 -c test.c
>> "test.c", line 13: identifier redeclared: test_func
>> current : function(pointer to const struct a_struct {int a, int b, array[-1] of pointer to char c}) returning pointer to void
>> previous: function(pointer to const struct a_struct {int a, int b, array[-1] of pointer to char c}) returning pointer to void : "test.c", line 4
>> c99: acomp failed for test.c
>>
>>
>> If either the flex array is removed from the structure, or const is removed from
>> test_func argument, test.c will compile. Compiling with -O0 doesn't help.
>
> What if you define FLEX_ARRAY to 1, or even 0?I tried that with my test.c example and '1' works, but not '0'. I'll try setting FLEX_ARRAY to 1 and running git's test suite on Monday.
Show 5 quoted lines
> If neither of those work then I'd simply remove the const. Generated > code should be exactly the same with gcc. There is no const with > sizeof_delta_index() which is already inconsistent. > > Kind of weird nevertheless.
Yes.
-brandon