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

Re: [PATCH 0/5] Header includes cleanup

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 31, 2009, 16:04 UTC
Message-ID
<7vk56565m1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200903310859.36035.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
> I think it's a good thing that you started working on it even if in the end 
> we decide that we want these cleanup to be done otherwise. At least we will 
> hopefully have clarified our include header policy.

Before seeing a lot of patches to change #include all over the place, I'd like to see a simple guiding principle described, not just a subjective "I think this makes things better" but with "... because of X and Y and Z".

The document Documentation/CodingGuidelines describes the only policy that exists currently: git-compat-util.h must be the first thing the compiler sees. The language should probably be stronger than what appears there:

 - The first #include in C files, except in platform specific
   compat/ implementations, should be git-compat-util.h or another
   well-known header file that includes it at the beginning, namely
   cache.h or builtin.h.

Even though http.h may include "cache.h" at the very beginning, I'd rather not to see http-walker.c lose inclusion of "cache.h". It will force us to remember that http.h is Ok to include as the first file, and that won't scale.

The reason git-compat-util.h must be the first is because inclusion of all the system header files is supposed to happen there, and there are some platforms that have broken system header dependencies we do not want application writers to care about, and the compat-util header knows about them.

Previous: Christian CouderNext: Christian Couder
Message 10 of 17 in “Header includes cleanup”
  1. 0/5 Header includes cleanupNathaniel P Dawson, Mar 30, 2009
  2. 1/5 Header includes cleanupNathaniel P Dawson, Mar 30, 2009
  3. 2/5 Header includes cleanupNathaniel P Dawson, Mar 30, 2009
  4. 3/5 Header includes cleanupNathaniel P Dawson, Mar 30, 2009
  5. 4/5 Header includes cleanupNathaniel P Dawson, Mar 30, 2009
  6. 5/5 Header includes cleanupNathaniel P Dawson, Mar 30, 2009
  7. Johannes SixtMar 30, 2009
  8. Nathaniel P DawsonMar 30, 2009
  9. Christian CouderMar 31, 2009
  10. Junio C HamanoMar 31, 2009
  11. Christian CouderApr 2, 2009
  12. Junio C HamanoApr 2, 2009
  13. Jeff KingApr 2, 2009
  14. Christian CouderApr 3, 2009
  15. Jeff KingApr 3, 2009
  16. Christian CouderApr 3, 2009
  17. Christian CouderMar 31, 2009

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.