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

Re: [PATCH v3 2/2] headers: include dependent headers

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Sep 7, 2014, 21:57 UTC
Message-ID
<540CD4E4.7060600@ramsay1.demon.co.uk>
In-Reply-To
<20140907203715.GB61326@gmail.com>
On 07/09/14 21:37, David Aguilar wrote:
Show 30 quoted lines
> On Sun, Sep 07, 2014 at 12:01:00PM +0100, Ramsay Jones wrote:
>> On 07/09/14 11:35, René Scharfe wrote:
>>> Am 07.09.2014 um 11:36 schrieb David Aguilar:
>>>> Add dependent headers so that including a header does not
>>>> require including additional headers.
>>>>
>>>> This makes it so that "gcc -c $header" succeeds for each header.
>>>
>>>> diff --git a/cache.h b/cache.h
>>>> index 4d5b76c..8b827d7 100644
>>>> --- a/cache.h
>>>> +++ b/cache.h
>>>> @@ -1,7 +1,6 @@
>>>>   #ifndef CACHE_H
>>>>   #define CACHE_H
>>>>
>>>> -#include "git-compat-util.h"
>>>>   #include "strbuf.h"
>>>>   #include "hashmap.h"
>>>>   #include "advice.h"
>>>
>>> Oh, that's a new change and worth mentioning in the commit message.
>>
>> Hmm, does this not break git? Unless you also change each '.c' file which
>> includes cache.h to also include git-compat-util.h first, then I suspect
>> (if nothing else) file I/O may be broken. (see _FILE_OFFSET_BITS).
>>
>> Also, see Documentation/CodingGuidelines (lines 331-333).
> 
> This one should be okay because hashmap.h includes git-compat-util.h.

It is important that each compilation unit include 'git-compat-util.h' at the start. From the CodingGuidelines we see that 'cache.h' and 'builtin.h' are *blessed* headers which can be used instead. (I have always thought that this was a mistake; it would be much easier to just stick to using 'git-compat-util.h' at the top of each '.c' file ;-)

The fact that hashmap.h happens to include git-compat-util.h is not at all relevant here.

> 
> Jonathan will be re-rolling so I'll definitely read and test the
> patches when they're ready.  They'll probably be a more focused,
> surgical change then this version.
OK.

ATB, Ramsay Jones

Previous: David Aguilar
Message 5 of 5 in “headers: include dependent headers”
  1. 2/2 headers: include dependent headersDavid Aguilar, Sep 7, 2014
  2. René ScharfeSep 7, 2014
  3. Ramsay JonesSep 7, 2014
  4. David AguilarSep 7, 2014
  5. Ramsay JonesSep 7, 2014

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.