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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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]

> 1:  f7d50cef3b ! 1:  e6a93208b2 Add missing includes and forward declares
>     @@ -1,6 +1,13 @@
>      Author: Elijah Newren <newren@xxxxxxxxx>
>      
>     -    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@xxxxxxxxxxxxxxxxxxxx>
---
 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux