Thread (1 message) 1 message, 1 author, 2021-11-18

Re: [PATCH v2 1/1] git-compat-util: add a test balloon for C99 support

From: Junio C Hamano <hidden>
Date: 2021-11-18 19:10:54

"brian m. carlson" [off-list ref] writes:
On 2021-11-17 at 03:01:57, Jeff King wrote:
quoted
Yes, but I'm not at all worried about breaking our CI. That's just a
patch away from fixing. I'm much more worried about confused users
building from source, because helping them is more difficult to scale.
That's one of the reasons I had proposed the current patch, because it
pukes in a very noticeable way with directives on where to look to
continue.  Just using C99 features means that Git breaks in a very
subtle way where the user compiling may not be familiar with C and may
not know how to fix it otherwise.  For example, my previous employer
ships Git, but many of the folks who are doing the package updates are
not C programmers.
I wonder if this would work, then.

 Makefile   | 3 ++-
 revision.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git c/Makefile w/Makefile
index 201437e9d4..454118d86b 100644
--- c/Makefile
+++ w/Makefile
@@ -1218,7 +1218,8 @@ endif
 # Set CFLAGS, LDFLAGS and other *FLAGS variables. These might be
 # tweaked by config.* below as well as the command-line, both of
 # which'll override these defaults.
-CFLAGS = -g -O2 -Wall -std=gnu99
+# Older versions of GCC may require adding "-std=gnu99" at the end.
+CFLAGS = -g -O2 -Wall
 LDFLAGS =
 CC_LD_DYNPATH = -Wl,-rpath,
 BASIC_CFLAGS = -I.
diff --git c/revision.c w/revision.c
index 78c1ceea7b..5390a479b3 100644
--- c/revision.c
+++ w/revision.c
@@ -49,7 +49,8 @@ void show_object_with_name(FILE *out, struct object *obj, const char *name)
 	 * This "for (const char *p = ..." is made as a first step towards
 	 * making use of such declarations elsewhere in our codebase.  If
 	 * it causes compilation problems on your platform, please report
-	 * it to the Git mailing list at git@vger.kernel.org.
+	 * it to the Git mailing list at git@vger.kernel.org. In the meantime,
+	 * adding -std=gnu99 to CFLAGS may help if you are with older GCC.
 	 */
 	for (const char *p = name; *p && *p != '\n'; p++)
 		fputc(*p, out);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help