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

Re: Unused #include statements

From
Robert Schiele <rschiele@gmail.com>
Date
Jan 15, 2015, 04:14 UTC
Message-ID
<CAObFj3wC6ezNQfAYvtepBdW3S0hv8c4_fXYTo-zp4wwddx3QXg@mail.gmail.com>
In-Reply-To
<CAKJhZwR+iMYAMCxurgc7z2dhqoqx_RxV1G4Jh3phPAOGptp_XQ@mail.gmail.com>
Hi Zoltan,

I can't make a statement for the git project but I consider this kind of brute-force removal a very problematic approach for languages like C and C++. The reason for that is simple: Often header files include other header files since their content depends on those other header files. Let's assume a header file a.h includes b.h. Now consider a file c.c includes both a.h and b.h since they are actually using stuff from both of them. Your brute-force approach would now remove b.h since it is indirectly pulled in through a.h. While the removal would no lead to technially incorrect code it would no longer reflect the semantical situation (since c.c still uses stuff from b.h). Even worse is that if you later modify c.c to no longer use stuff from a.h you could no longer remove a.h since that way you would break the chain to b.h.

Thus doing those kind of brute-force removals generally makes the include structure in a project very fragile. The analysis itself you did is still useful to identify header files that can potentially be removed but removing them without further analysis I would consider problematic.

Robert
Previous: Zoltan KlingerNext: Jeff King
Message 2 of 8 in “Unused #include statements”
  1. Zoltan KlingerJan 15, 2015
  2. Robert SchieleJan 15, 2015
  3. Jeff KingJan 15, 2015
  4. Junio C HamanoJan 15, 2015
  5. Jeff KingJan 15, 2015
  6. Junio C HamanoJan 15, 2015
  7. Jeff KingJan 16, 2015
  8. Zoltan KlingerJan 20, 2015

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.