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