Re: [PATCH 0/9] Add missing includes and forward declares
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 13, 2018, 18:24 UTC
- Message-ID
- <xmqqr2j25dlm.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180811173406.GA9119@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> The rule in Git has always been that your very first include must > always be "git-compat-util.h" or an equivalent header that includes it > first (like "cache.h"). This is mentioned in CodingGuidelines.
Glad to see that you already have written the above so I don't have to ;-)
As things are slowly moving out of the so-far kitchen-sink "cache.h" into more specific subsystem headers (like object-store.h), we may actually want to tighten the "header that includes it first" part a bit in the future, so that 'git grep cache.h' would give us a more explicit and a better picture of what really depends on knowing what the lowest level plumbing API are built around.
> So I think the better test is a two-line .c file with: > > #include "git-compat-util.h" > #include $header_to_check
But until that tightening happens, I do not actually mind the two-line .c file started with inclusion of cache.h instead of git-compat-util.h. That would limit the scope of this series further.
> I wonder if there's an easy way to check. I guess adding '-Dint=foo' to > the command line, and then putting '#undef int' at the top of > git-compat-util would catch just about any code the compiler sees that > doesn't have git-compat-util included. :)
;-).