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

Re: [PATCH] strbuf: use designated initializers in STRBUF_INIT

From
Johannes Sixt <j6t@kdbg.org>
Date
Jul 13, 2017, 22:24 UTC
Message-ID
<2f7f7af2-585c-9374-34e3-e34680678935@kdbg.org>
In-Reply-To
<87d195zcy0.fsf@gmail.com>
Am 12.07.2017 um 21:12 schrieb Ævar Arnfjörð Bjarmason:
> I think in the context of this desire Johannes Sixt's "Actually, I'm
> serious [about let's compile with c++]"[1] should be given some more
> consideration.
Thank you for your support.
Show 5 quoted lines
> I've just compiled Git with it and it passes all tests. I think the
> endeavor is worthwhile in itself as C++ source-level compatibility for
> git.git is clearly easy to achieve, and would effectively give us access
> to more compilers (albeit in different modes, but they may discover
> novel bugs that also apply to the C mode code).

Please keep in mind that my patches only show that it can be done. Nevertheless, the result is far, far away from valid C++ code. It can be compiled by GCC (thanks to its -fpermissive flag) and happens to produce something that works. But that does not mean that other compilers would grok it.

Source-level compatibility is only necessary as a stop gap in the transition to C++. If the transition is not going to happen, I doubt that there is any value. It is simply too much code churn for too little gain. The real gains are in the features of C++(11,14).

> But why do it? Aside from the "more compilers" argument, we may find
> that it's going to be much easier to use some C99 features we want by
> having C++ source-level compatibility, and on compilers like that may
> not support those features in C use the C++ mode that may support those.

I would be happy to learn about a C99 feature where C++ mode of some compiler would help.

The only C99 feature mentioned so far was designated initializers. Unfortunately, that actually widens the gap between C and C++, not lessens it. (C++ does not have designated initializers, and they are not on the agenda.)

> If not C++ support would be interesting for other reasons. Johannes
> Sixt: It would be very nice to get those patches on-list.

I don't think it's worth to swamp the list with the patches at this time. Interested parties can find them here:

https://github.com/j6t/git.git c-plus-plus

I may continue the work, slowly and as long as I find it funny. It's just mental exercise, unless the Git community copies the GCC Steering Committee's mindeset with regard to C++ in the code base (https://gcc.gnu.org/ml/gcc/2010-05/msg00705.html).

-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 39 in “strbuf: use designated initializers in STRBUF_INIT”
  1. strbuf: use designated initializers in STRBUF_INITJeff King, Jul 10, 2017
  2. Ben PeartJul 10, 2017
  3. Jeff KingJul 10, 2017
  4. Ben PeartJul 10, 2017
  5. Mike HommeyJul 11, 2017
  6. Junio C HamanoJul 11, 2017
  7. Ævar Arnfjörð BjarmasonJul 12, 2017
  8. Junio C HamanoJul 12, 2017
  9. Johannes SixtJul 13, 2017
  10. Junio C HamanoJul 10, 2017
  11. Stefan BellerJul 10, 2017
  12. Junio C HamanoJul 10, 2017
  13. Andreas SchwabJul 10, 2017
  14. Johannes SixtJul 10, 2017
  15. Junio C HamanoJul 10, 2017
  16. Johannes SixtJul 10, 2017
  17. Junio C HamanoJul 10, 2017
  18. Junio C HamanoJul 14, 2017
  19. Stefan BellerJul 14, 2017
  20. Jeff KingJul 14, 2017
  21. Junio C HamanoJul 14, 2017
  22. Junio C HamanoJul 14, 2017
  23. objects: scope count variable to loopStefan Beller, Jul 19, 2017
  24. Brandon WilliamsJul 19, 2017
  25. Jeff KingJul 24, 2017
  26. Stefan BellerJul 24, 2017
  27. Jeff KingJul 24, 2017
  28. Ævar Arnfjörð BjarmasonJul 14, 2017
  29. Junio C HamanoJul 14, 2017
  30. Mike HommeyJul 14, 2017
  31. Jeff KingJul 15, 2017
  32. Jeff KingJul 11, 2017
  33. brian m. carlsonJul 11, 2017
  34. Stefan BellerJul 11, 2017
  35. brian m. carlsonJul 11, 2017
  36. Johannes SixtJul 11, 2017
  37. brian m. carlsonJul 12, 2017
  38. Johannes SixtJul 12, 2017
  39. Brandon WilliamsJul 10, 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.