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

Re: [RFC PATCH v2 1/2] Makefile: add check-headers target

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 7, 2014, 19:42 UTC
Message-ID
<20140907194227.GA1611@google.com>
In-Reply-To
<1410049821-49861-1-git-send-email-davvid@gmail.com>
Hi,
David Aguilar wrote:
> --- /dev/null
> +++ b/check-headers.sh
> @@ -0,0 +1,29 @@
[...]
> +	"$@" -Wno-unused -I"$subdir" -c -o "$header".check -x c - <"$header" &&

All .c files in git are supposed to start by #include-ing git-compat-util.h, cache.h, or builtin.h to set the appropriate feature test macros and include system headers.

Headers rely on that for basic types like int32_t. They don't need to include git-compat-util.h because the .c file that included them would have already, and .h files #include-ed by git-compat-util.h especially *shouldn't* #include the compat header, so how about something like the following for squashing in?

A side-thought: as long as we're building pre-compiled headers, could we use them in the build?

Thanks, Jonathan

diff --git a/check-headers.sh b/check-headers.sh
index bf85c41..08ca136 100755
--- a/check-headers.sh
+++ b/check-headers.sh
@@ -18,7 +18,7 @@ git ls-files *.h |
 while read header
 do
 	echo "HEADER $header" &&
-	"$@" -Wno-unused -x c -c -o "$header".bin - <"$header" &&
+	"$@" -Wno-unused -x c -include git-compat-util.h -c -o "$header".bin - <"$header" &&
 	rm "$header".bin ||
 	maybe_exit $?
 done
Previous: David AguilarNext: Junio C Hamano
Message 8 of 14 in “Makefile: add check-headers target”
  1. 1/2 Makefile: add check-headers targetDavid Aguilar, Sep 7, 2014
  2. 2/2 headers: include dependent headersDavid Aguilar, Sep 7, 2014
  3. René ScharfeSep 7, 2014
  4. Jonathan NiederSep 7, 2014
  5. Johannes SixtSep 7, 2014
  6. Jonathan NiederSep 7, 2014
  7. David AguilarSep 7, 2014
  8. Jonathan NiederSep 7, 2014
  9. Junio C HamanoSep 8, 2014
  10. Matthieu MoySep 8, 2014
  11. Junio C HamanoSep 8, 2014
  12. David AguilarSep 10, 2014
  13. Junio C HamanoSep 10, 2014
  14. Matthieu MoySep 10, 2014

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.