Re: [PATCH] objects: scope count variable to loop
- From
Stefan Beller <sbeller@google.com>
- Date
- Jul 24, 2017, 17:12 UTC
- Message-ID
- <CAGZ79kZafHBJOVwZzw_ii3T6_X24Uci4vUudp45r8-GTn0a4Sg@mail.gmail.com>
- In-Reply-To
- <20170724170813.scceigybl5d3fvdd@sigill.intra.peff.net>
On Mon, Jul 24, 2017 at 10:08 AM, Jeff King <peff@peff.net> wrote:
Show 20 quoted lines
> On Wed, Jul 19, 2017 at 11:23:42AM -0700, Brandon Williams wrote:
>
>> > object.c: In function ‘object_array_remove_duplicates’:
>> > object.c:404:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
>> > for (unsigned src = 0; src < nr; src++) {
>> > ^
>> > object.c:404:2: note: use option -std=c99 or -std=gnu99 to compile your code
>> >
>> > Using -std=c99 works for me.
>>
>> This would need a change to the makefile then wouldn't it?
>
> Actually, it complicates things even more, I'd think. We probably can't
> just blindly add "-std=c99" to CFLAGS, as not all compilers would
> support it (even if they _do_ support this construct).
>
> Interestingly I have no problems compiling it here. I wonder if Stefan's
> config.mak is supplying -std=c89 or some other restrictive flag. Or if
> his compiler is a different version (though I tried with gcc-6, gcc-4.9,
> and clang-3.8).Before this patch, I only had CFLAGS += -g -O0 in config.mak (as I switched working directories recently), I'll throw in DEVELOPER=1
My compiler version is ancient (gcc 4.8.4-2ubuntu1~14.04.3) apparently (why did I never check in this environment?)