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

Re: [PATCHv4 0/6] Add missing includes and forward declares

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Aug 16, 2018, 00:19 UTC
Message-ID
<b8553a50-6b97-2b45-2f7b-cfe2576548cb@ramsayjones.plus.com>
In-Reply-To
<20180815175410.5726-1-newren@gmail.com>
On 15/08/18 18:54, Elijah Newren wrote:
> This series fixes compilation errors when using a simple test.c file that
> includes git-compat-util.h and then exactly one other header (and repeating
> this for different headers of git).
> 
[snip]
Show 13 quoted lines
> 1:  f7d50cef3b ! 1:  e6a93208b2 Add missing includes and forward declares
>     @@ -1,6 +1,13 @@
>      Author: Elijah Newren <newren@gmail.com>
>      
>     -    Add missing includes and forward declares
>     +    Add missing includes and forward declarations
>     +
>     +    I looped over the toplevel header files, creating a temporary two-line C
>     +    program for each consisting of
>     +      #include "git-compat-util.h"
>     +      #include $HEADER
>     +    This patch is the result of manually fixing errors in compiling those
>     +    tiny programs.

As a quick ("just before bedtime") exercise, I tried adding a Makefile target to perform a similar check. The result is given below, but I haven't had time to look too closely at the results:

  $ make -k hdr-check >zzz 2>&1
  $ grep error zzz | wc -l
  18
  $ grep warning zzz | wc -l
  21
  $ grep error zzz | cut -d: -f1 | grep -v make | uniq -c | sort -nr
       11 refs/refs-internal.h
        2 unicode-width.h
        2 json-writer.h
        1 refs/ref-cache.h
        1 commit-slab-impl.h
  $ grep warning zzz | cut -d: -f1 | grep -v make | uniq -c | sort -nr
        7 refs/refs-internal.h
        5 delta-islands.h
        2 unicode-width.h
        2 midx.h
        2 commit-reach.h
        1 refs/ref-cache.h
        1 refs/packed-backend.h
        1 pack-bitmap.h
  $ 
  
BTW, I happen to be on the 'pu' branch.

I think some of the errors are due to missing compiler flags (-I, -D, etc); which flags did you pass to the compiler?

Well, it killed 15min. before bed! ;-)

ATB, Ramsay Jones

-- >8 --
Subject: [PATCH] Makefile: add a hdr-check target
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/Makefile b/Makefile
index 9923db888c..798396c52e 100644
--- a/Makefile
+++ b/Makefile
@@ -2684,6 +2684,16 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
 .PHONY: sparse $(SP_OBJ)
 sparse: $(SP_OBJ)
 
+EXCEPT_HDRS := ./compat% ./xdiff% ./ewah%
+CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(LIB_H))
+HCO = $(patsubst %.h,%.hco,$(CHK_HDRS))
+
+$(HCO): %.hco: %.h FORCE
+	$(CC) -Wall -include git-compat-util.h -I. -o /dev/null -c -xc $<
+
+.PHONY: hdr-check $(HCO)
+hdr-check: $(HCO)
+
 .PHONY: style
 style:
 	git clang-format --style file --diff --extensions c,h
-- 
2.18.0
Previous: Jonathan NiederNext: Junio C Hamano
Message 12 of 14 in “[PATCHv4 0/6] Add missing includes and forward declares”
  1. Elijah NewrenAug 15, 2018
  2. 6/6 Remove forward declaration of an enumElijah Newren, Aug 15, 2018
  3. Jonathan NiederAug 15, 2018
  4. 4/6 urlmatch.h: fix include guardElijah Newren, Aug 15, 2018
  5. 2/6 alloc: make allocate_alloc_state and clear_alloc_state more consistentElijah Newren, Aug 15, 2018
  6. Jonathan NiederAug 15, 2018
  7. 5/6 compat/precompose_utf8.h: use more common include guard styleElijah Newren, Aug 15, 2018
  8. 3/6 Move definition of enum branch_track from cache.h to branch.hElijah Newren, Aug 15, 2018
  9. 1/6 Add missing includes and forward declarationsElijah Newren, Aug 15, 2018
  10. Jonathan NiederAug 15, 2018
  11. Jonathan NiederAug 15, 2018
  12. Ramsay JonesAug 16, 2018
  13. Junio C HamanoAug 16, 2018
  14. Jeff KingAug 16, 2018

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.