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

Re: [PATCH 0/5] Header includes cleanup

From
Jeff King <peff@peff.net>
Date
Apr 2, 2009, 11:27 UTC
Message-ID
<20090402112705.GD14599@sigill.intra.peff.net>
In-Reply-To
<7v8wmjk4p6.fsf@gitster.siamese.dyndns.org>
On Wed, Apr 01, 2009 at 10:25:09PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> > - a header file should be included in a C file only if it is needed to 
> > compile the C file (it is not ok to include it only because it includes 
> > many other headers that are needed)
> 
> If that is the rule, perhaps the problem lies not in a .c program that
> includes such a .h header, but in the .h itself that includes many other
> header files.

If this were combined with splitting gigantic .h files (like cache.h) into smaller logical units, then we could in theory speed up recompilation times with make (we would also need to correctly track header dependencies, but gcc -M can do this fairly easily).

But it does come at the price of actually having to consider which include files are necessary. I can't think of more than half a dozen times in the last year I have actually had to add a #include while working on a git .c file, mostly because everything and the kitchen sink is included by cache.h.

So I don't know if it is worth it.
-Peff
Previous: Junio C HamanoNext: Christian Couder
Message 13 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.