# Compilation errors in git.pu/refs/reftable-backend.c

5 messages from 2020-04-27 to 2020-04-27. Participants: Torsten Bögershausen, Han-Wen Nienhuys, Jeff King, Carlo Marcelo Arenas Belón, brian m. carlson.
Thread: https://gitlist.dev/t/53329

## Torsten Bögershausen, 2020-04-27 04:34

Subject: Compilation errors in git.pu/refs/reftable-backend.c
Message-ID: <575af27b-3823-2db5-ad3b-3c6cd7a95faa@web.de>
URL: https://gitlist.dev/e/575af27b-3823-2db5-ad3b-3c6cd7a95faa%40web.de

```
Folks, after the integration of the reftable branch:
Merge branch 'hn/reftable' into pu

My historic (?) compiler stumbles over this code here:
refs/reftable-backend.c
   for (int i = 0; i < transaction->nr; i++) {

So I think we could easily avoid the (for int i) construction.
The other observation could be, why we use an "int", when "nr" is
defined as a size_t ?

struct ref_transaction {
	struct ref_store *ref_store;
	struct ref_update **updates;
	size_t alloc;
	size_t nr;
	enum ref_transaction_state state;
	void *backend_data;
};

Thanks for working on Git

```

## Han-Wen Nienhuys, 2020-04-27 12:05

Subject: Re: Compilation errors in git.pu/refs/reftable-backend.c
Message-ID: <CAFQ2z_O7z2prvnE+v-0nzC3=2mmUBHgFVF+iRqRn-7QyRQxOqg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFQ2z_O7z2prvnE%2Bv-0nzC3%3D2mmUBHgFVF%2BiRqRn-7QyRQxOqg%40mail.gmail.com
In-Reply-To: <575af27b-3823-2db5-ad3b-3c6cd7a95faa@web.de>

```
On Mon, Apr 27, 2020 at 6:34 AM Torsten Bögershausen <tboegi@web.de> wrote:
>
> Folks, after the integration of the reftable branch:
> Merge branch 'hn/reftable' into pu

thanks, I'll fix that.

I don't understand why Git doesn't enforce this, though.  Couldn't
-Wdeclaration-after-statement be added to the Makefile if the compiler
supported it?

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

```

## Jeff King, 2020-04-27 12:13

Subject: Re: Compilation errors in git.pu/refs/reftable-backend.c
Message-ID: <20200427121328.GA1725867@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20200427121328.GA1725867%40coredump.intra.peff.net
In-Reply-To: <CAFQ2z_O7z2prvnE+v-0nzC3=2mmUBHgFVF+iRqRn-7QyRQxOqg@mail.gmail.com>

```
On Mon, Apr 27, 2020 at 02:05:12PM +0200, Han-Wen Nienhuys wrote:

> On Mon, Apr 27, 2020 at 6:34 AM Torsten Bögershausen <tboegi@web.de> wrote:
> >
> > Folks, after the integration of the reftable branch:
> > Merge branch 'hn/reftable' into pu
> 
> thanks, I'll fix that.
> 
> I don't understand why Git doesn't enforce this, though.  Couldn't
> -Wdeclaration-after-statement be added to the Makefile if the compiler
> supported it?

Try building with "make DEVELOPER=1" (or putting DEVELOPER=1 in your
config.mak), which will turn on warnings and enable -Werror. See
config.mak.dev for the complete list.

-Peff

```

## Carlo Marcelo Arenas Belón, 2020-04-27 13:13

Subject: Re: Compilation errors in git.pu/refs/reftable-backend.c
Message-ID: <20200427131312.GB61348@Carlos-MBP>
URL: https://gitlist.dev/e/20200427131312.GB61348%40Carlos-MBP
In-Reply-To: <CAFQ2z_O7z2prvnE+v-0nzC3=2mmUBHgFVF+iRqRn-7QyRQxOqg@mail.gmail.com>

```
On Mon, Apr 27, 2020 at 02:05:12PM +0200, Han-Wen Nienhuys wrote:
> 
> I don't understand why Git doesn't enforce this, though.  Couldn't
> -Wdeclaration-after-statement be added to the Makefile if the compiler
> supported it?

not sure if that flag will catch it, but from what I recall, that
specific feature was only available in C99 while git's codebase
targets C89 (need to build with --std=gnu89 as some GNU extensions
are already needed).

see the "For C programs" section in Documentation/CodingGuidelines for
details.

Carlo

```

## brian m. carlson, 2020-04-27 23:26

Subject: Re: Compilation errors in git.pu/refs/reftable-backend.c
Message-ID: <20200427232629.GI6421@camp.crustytoothpaste.net>
URL: https://gitlist.dev/e/20200427232629.GI6421%40camp.crustytoothpaste.net
In-Reply-To: <20200427131312.GB61348@Carlos-MBP>

```
On 2020-04-27 at 13:13:12, Carlo Marcelo Arenas Belón wrote:
> On Mon, Apr 27, 2020 at 02:05:12PM +0200, Han-Wen Nienhuys wrote:
> > 
> > I don't understand why Git doesn't enforce this, though.  Couldn't
> > -Wdeclaration-after-statement be added to the Makefile if the compiler
> > supported it?
> 
> not sure if that flag will catch it, but from what I recall, that
> specific feature was only available in C99 while git's codebase
> targets C89 (need to build with --std=gnu89 as some GNU extensions
> are already needed).

I think we had chosen to preserve this behavior because MSVC didn't
support C99.  We may wish to change our approach now that MSVC supports
a reasonable subset of it and GCC and Clang are available for almost
every system out there.

I don't think it's unreasonable to expect folks to use a compiler
supporting a standard that is now more than two decades old.

Of course, that doesn't affect the present series, but it is a thing we
should consider.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

```
