From: Jeff King <peff@peff.net>
To: Thiago Farina <tfransosi@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: header file at a top
Date: Sun, 18 Dec 2011 00:43:52 -0500 [thread overview]
Message-ID: <20111218054352.GB4462@sigill.intra.peff.net> (raw)
In-Reply-To: <CACnwZYdSPPhLyu6Oi3k2aNzYqvmD=xDYWvCEd2ofyJSntqKdJg@mail.gmail.com>
On Sat, Dec 17, 2011 at 07:57:42PM -0200, Thiago Farina wrote:
> I don't understand why in git the .h file is not included as the first
> substantive line of the .c file.
>
> i.e:
>
> foo.c
> --------------------------------------------------------------------
> #include "foo.h"
>
> /* in alphabetical order */
> #include "bar.h"
> #include "tiz.h"
>
> Any particular reason we include the corresponding header file at some
> random position in the source file?
The first include in any git source file should be either
"git-compat-util.h", or something that includes it (usually "cache.h").
This introduces compatibility wrappers and definitions which may be used
by other headers.
After that, the next one could be "foo.h", and I do tend to like that
style (since it gives a check that foo.h has no surprising header
dependencies). But I think we simply don't bother caring about header
dependencies in git (i.e., we do have recursive includes in some places,
but we don't require them, and in practice the compiler will tell us if
a source file fails to include a depended-upon header).
-Peff
prev parent reply other threads:[~2011-12-18 5:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-17 21:57 header file at a top Thiago Farina
2011-12-18 5:43 ` Jeff King [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111218054352.GB4462@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=tfransosi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).