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

Re: Fixing the warning about warning(""); was: Re: [PATCH] difftool.c: mark a file-local symbol with static

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 26, 2017, 11:37 UTC
Message-ID
<alpine.DEB.2.20.1701261226220.3469@virtualbox>
In-Reply-To
<546179e0-1d6e-86f7-00cf-e13218b76de1@kdbg.org>
Hi Hannes,
On Thu, 26 Jan 2017, Johannes Sixt wrote:
Show 5 quoted lines
> Am 25.01.2017 um 23:01 schrieb Jeff King:
> > +#pragma GCC diagnostic ignored "-Wformat-zero-length"
> 
> Last time I used #pragma GCC in a cross-platform project, it triggered
> an "unknown pragma" warning for MSVC.

It is starting to become a little funny how many ways we can discuss the resolution of the GCC compiler warning.

And it starts to show: we try to solve the thing in so many ways, just to avoid the obviously most-trivial patch to change warning(""); to warning("%s", "") (the change to warning(" "); would change behavior, but I would be fine with that, too).

I am not really interested in any of these complicated workarounds. If you gentle people decide they are better in Git's source code, go ahead. I do not have to like what you are doing, I just have to work with it.

Show 7 quoted lines
> (It was the C++ compiler, I don't know if the C compiler would also
> warn.) It would have to be spelled like this:
> 
> #pragma warning(disable: 4068)   /* MSVC: unknown pragma */
> #pragma GCC diagnostic ignored "-Wformat-zero-length"
> 
> Dscho mentioned that he's compiling with MSVC. It would do him a favor.

I am compiling with MSVC, and the idea is to tap into that large number of Windows developers who Git traditionally has had a really bad time attracting. From that perspective, I would say it would not only do me a favor, but anybody who builds Git for Windows using Visual Studio.

But we also have to consider whether it would do anybody a "dis-favor". #pragma statements are by definition highly dependent on the compiler. I have no idea whether there are developers out there building Git with C compilers other than GCC, clang or MSVC (as I did back in the days on IRIX and HP/UX), but there is quite the potential for problems here [*1*].

To keep Git's source code truly portable, the #pragma would have to be guarded by a GCC-specific #ifdef ... #endif.

Ciao, Dscho

Footnote *1*: This is just another instance where a discussion on the Git mailing list reminds me of http://thedailywtf.com/articles/The_Complicator_0x27_s_Gloves, as it tries to avoid an obvious solution by trying to come up with a different solution that in turn requires additional solutions to additional problems caused by the alternative solution.

Previous: Johannes SixtNext: Jeff King
Message 22 of 28 in “difftool.c: mark a file-local symbol with static”
  1. difftool.c: mark a file-local symbol with staticRamsay Jones, Nov 29, 2016
  2. Johannes SchindelinNov 30, 2016
  3. Ramsay JonesNov 30, 2016
  4. Junio C HamanoNov 30, 2016
  5. Jeff KingNov 30, 2016
  6. Ramsay JonesNov 30, 2016
  7. Jeff KingNov 30, 2016
  8. Junio C HamanoNov 30, 2016
  9. Ramsay JonesDec 1, 2016
  10. Jeff KingDec 1, 2016
  11. Junio C HamanoDec 1, 2016
  12. Jeff KingDec 1, 2016
  13. David AguilarJan 22, 2017
  14. Jeff KingJan 24, 2017
  15. Junio C HamanoJan 24, 2017
  16. Jeff KingJan 24, 2017
  17. Fixing the warning about warning(""); was: Re: [PATCH] difftool.c: mark a file-local symbol with staticJohannes Schindelin, Jan 25, 2017
  18. Jeff KingJan 25, 2017
  19. Junio C HamanoJan 25, 2017
  20. Jeff KingJan 25, 2017
  21. Johannes SixtJan 26, 2017
  22. Johannes SchindelinJan 26, 2017
  23. Jeff KingJan 26, 2017
  24. Jeff KingJan 26, 2017
  25. Junio C HamanoJan 26, 2017
  26. Johannes SchindelinJan 26, 2017
  27. Jeff KingJan 26, 2017
  28. Johannes SchindelinJan 26, 2017

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.