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

[PATCH] Add -Wdeclaration-after-statement to CFLAGS to help enforce the instructions in SubmittingPatches

From
Johan Herland <johan@herland.net>
Date
May 27, 2007, 14:39 UTC
Message-ID
<200705271639.35267.johan@herland.net>
In-Reply-To
<Pine.LNX.4.64.0705211347540.6410@racer.site>
Signed-off-by: Johan Herland <johan@herland.net>
---
On Monday 21 May 2007, Johannes Schindelin wrote:
Show 9 quoted lines
> 
> We do not appreciate C99 initializers, declarations after statements,
> or "0" instead of "NULL".
>
> [...]
> 
> +Also, variables have to be declared at the beginning of the block
> +(you can check this with gcc, using the -Wdeclaration-after-statement
> +option).

Why not automatically enforce it by putting -Wdeclaration-after-statement in the Makefile?

It should probably be protected by some GCC if-ery, but then again, so should this:
CC = gcc
Have fun!
...Johan
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 29243c6..4e91516 100644
--- a/Makefile
+++ b/Makefile
@@ -135,7 +135,7 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
 
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
-CFLAGS = -g -O2 -Wall
+CFLAGS = -g -O2 -Wall -Wdeclaration-after-statement
 LDFLAGS =
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
-- 
1.5.2.101.gee49f
Previous: Johannes SchindelinNext: Morten Welinder
Message 9 of 10 in “Submodule merge support”
  1. Submodule merge supportMartin Waitz, May 20, 2007
  2. Shawn O. PearceMay 21, 2007
  3. Martin WaitzMay 21, 2007
  4. Shawn O. PearceMay 21, 2007
  5. Junio C HamanoMay 21, 2007
  6. Alex RiesenMay 21, 2007
  7. Junio C HamanoMay 21, 2007
  8. SubmittingPatches: mention older C compiler compatibilityJohannes Schindelin, May 21, 2007
  9. Add -Wdeclaration-after-statement to CFLAGS to help enforce the instructions in SubmittingPatchesJohan Herland, May 27, 2007
  10. Morten WelinderMay 27, 2007

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.