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

Re: [PATCH] builtin/config: work around an unsized array forward declaration

From
Taylor Blau <me@ttaylorr.com>
Date
Jul 5, 2018, 19:35 UTC
Message-ID
<20180705193505.GA71957@syl.attlocal.net>
In-Reply-To
<20180705183445.30901-1-dev+git@drbeat.li>
On Thu, Jul 05, 2018 at 08:34:45PM +0200, Beat Bolli wrote:
Show 12 quoted lines
> As reported here[0], Microsoft Visual Studio 2017.2 and "gcc -pedantic"
> don't understand the forward declaration of an unsized static array.
> They insist on an array size:
>
>     d:\git\src\builtin\config.c(70,46): error C2133: 'builtin_config_options': unknown size
>
> The thread [1] explains that this is due to the single-pass nature of
> old compilers.
>
> To work around this error, introduce the forward-declared function
> usage_builtin_config() instead that uses the array
> builtin_config_options only after it has been defined.

Argh, I think that this is my fault (via: fb0dc3bac1 (builtin/config.c: support `--type=<type>` as preferred alias for `--<type>`, 2018-04-18)).

Thank you for the explanation above, and for the patch below. I reviewed it myself, and the fix seems to be appropriate.

Show 10 quoted lines
> Also use this function in all other places where usage_with_options() is
> called with the same arguments.
>
> [0]: https://github.com/git-for-windows/git/issues/1735
> [1]: https://groups.google.com/forum/#!topic/comp.lang.c.moderated/bmiF2xMz51U
>
> Fixes https://github.com/git-for-windows/git/issues/1735
>
> Reported-By: Karen Huang (via GitHub)
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>

Thanks, Taylor

Previous: Beat BolliNext: Jeff King
Message 2 of 7 in “builtin/config: work around an unsized array forward declaration”
  1. builtin/config: work around an unsized array forward declarationBeat Bolli, Jul 5, 2018
  2. Taylor BlauJul 5, 2018
  3. Jeff KingJul 5, 2018
  4. Beat BolliJul 5, 2018
  5. Jeff KingJul 5, 2018
  6. Junio C HamanoJul 6, 2018
  7. Kim GybelsJul 7, 2018

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.