You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Jan Schlicht <ja...@mesosphere.io> on 2015/11/10 17:35:17 UTC

Header include order

Currently there is no consensus on the order of includes. I'm currently
working on MESOS-2275 and would suggest, that we follow the rules from the
Google C++ Style Guide (
https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes)
as much as possible but also follow the current grouping of includes by
their level of indirection.

One important question that came up on RR (
https://reviews.apache.org/r/39449/) is, if we should include the "related
header" of a source file first. Currently this header is included like any
other header. How about we should change that practice and include this
header first to avoid hidden dependencies?

-- 
*Jan Schlicht*
Distributed Systems Engineer, Mesosphere

Re: Header include order

Posted by Alexander Rojas <al...@mesosphere.io>.
I remember discussing this issue a while ago on the mailing list [1]. There were two votes in favor from Benjamin Hindman and Benjamin Mahler, and no votes against it. There’s also an accepted Jira entry MESOS-2673 to add the ordering into our style guide.

[1] http://mail-archives.apache.org/mod_mbox/mesos-dev/201505.mbox/%3CCADcAm2sLFJL2H4WVXjxBpXgYkfxFS3CiCCfPWk_3q4Q-6mTCNQ@mail.gmail.com%3E <http://mail-archives.apache.org/mod_mbox/mesos-dev/201505.mbox/%3CCADcAm2sLFJL2H4WVXjxBpXgYkfxFS3CiCCfPWk_3q4Q-6mTCNQ@mail.gmail.com%3E>
> On 10 Nov 2015, at 17:35, Jan Schlicht <ja...@mesosphere.io> wrote:
> 
> Currently there is no consensus on the order of includes. I'm currently
> working on MESOS-2275 and would suggest, that we follow the rules from the
> Google C++ Style Guide (
> https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes)
> as much as possible but also follow the current grouping of includes by
> their level of indirection.
> 
> One important question that came up on RR (
> https://reviews.apache.org/r/39449/) is, if we should include the "related
> header" of a source file first. Currently this header is included like any
> other header. How about we should change that practice and include this
> header first to avoid hidden dependencies?
> 
> -- 
> *Jan Schlicht*
> Distributed Systems Engineer, Mesosphere


Re: Header include order

Posted by Jörg Schad <jo...@mesosphere.io>.
We posted a fix for the inconsistent include order of <gtest/gtest.h> and <
gmock/gmock.h> making it consistent with the Google Styleguide (
https://google.github.io/styleguide/cppguide
.html#Names_and_Order_of_Includes).

Check the Jira/Review Request for details:
https://issues.apache.org/jira/browse/MESOS-3879
https://reviews.apache.org/r/40142/

Thanks,
Joerg


On Tue, Nov 10, 2015 at 6:37 PM, Alex Rukletsov <al...@mesosphere.com> wrote:

> As a side note, we also sometimes include GTEST headers ("gtest/gtest.h", "
> gmock/gmock.h") in tests files first. However, GTEST is *just* a 3rdparty
> library, which means STL headers should go first. I would like to point out
> that this is not intentional even though you may see this in our codebase,
> so please do not follow this pattern and feel free to fix it if you're
> modifying a test file.
>
> On Tue, Nov 10, 2015 at 5:35 PM, Jan Schlicht <ja...@mesosphere.io> wrote:
>
> > Currently there is no consensus on the order of includes. I'm currently
> > working on MESOS-2275 and would suggest, that we follow the rules from
> the
> > Google C++ Style Guide (
> >
> >
> https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
> > )
> > as much as possible but also follow the current grouping of includes by
> > their level of indirection.
> >
> > One important question that came up on RR (
> > https://reviews.apache.org/r/39449/) is, if we should include the
> "related
> > header" of a source file first. Currently this header is included like
> any
> > other header. How about we should change that practice and include this
> > header first to avoid hidden dependencies?
> >
> > --
> > *Jan Schlicht*
> > Distributed Systems Engineer, Mesosphere
> >
>

Re: Header include order

Posted by Alex Rukletsov <al...@mesosphere.com>.
As a side note, we also sometimes include GTEST headers ("gtest/gtest.h", "
gmock/gmock.h") in tests files first. However, GTEST is *just* a 3rdparty
library, which means STL headers should go first. I would like to point out
that this is not intentional even though you may see this in our codebase,
so please do not follow this pattern and feel free to fix it if you're
modifying a test file.

On Tue, Nov 10, 2015 at 5:35 PM, Jan Schlicht <ja...@mesosphere.io> wrote:

> Currently there is no consensus on the order of includes. I'm currently
> working on MESOS-2275 and would suggest, that we follow the rules from the
> Google C++ Style Guide (
>
> https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
> )
> as much as possible but also follow the current grouping of includes by
> their level of indirection.
>
> One important question that came up on RR (
> https://reviews.apache.org/r/39449/) is, if we should include the "related
> header" of a source file first. Currently this header is included like any
> other header. How about we should change that practice and include this
> header first to avoid hidden dependencies?
>
> --
> *Jan Schlicht*
> Distributed Systems Engineer, Mesosphere
>