mesos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vinod Kone <vinodk...@apache.org>
Subject Re: Order of includes
Date Wed, 18 Jan 2017 10:34:24 GMT
@Mpark, @Yan and @Benjamin: Would one of you be willing to send a review
request that sweeps our code base to enforce this change? It's confusing if
we have some files following the rule and some that doesn't.

On Wed, Dec 21, 2016 at 10:11 PM, Alex Rukletsov <alex@mesosphere.com>
wrote:

> Yes!
>
> https://issues.apache.org/jira/browse/MESOS-6827
>
> On Mon, Dec 19, 2016 at 8:49 AM, Yan Xu <xujyan@apple.com> wrote:
>
> > The example is helpful. Thanks!
> >
> > I have no objection to sticking to the new rule then. But the we have to:
> >
> > - For contributors and committers, start using the new style when
> creating
> > new files today.
> > - Fix the existing include order hopefully with the help of tools like
> > clang-tidy and have it enforce the style going forward.
> >
> > Agreed?
> >
> > ---
> > @xujyan <https://twitter.com/xujyan>
> >
> > On Fri, Dec 16, 2016 at 8:54 PM, Benjamin Bannier <
> > benjamin.bannier@mesosphere.io> wrote:
> >
> > > Hi,
> > >
> > > > How does putting your own header at the top (vs. ~the bottom) help
> > ensure
> > > > "a header file always includes all symbols it requires”?
> > >
> > >
> > > Given an incomplete header
> > >
> > >     // foo.hpp
> > >     std::string f();
> > >
> > >     // foo.cpp
> > >     #include “foo.hpp”
> > >     #include <string>
> > >
> > >     std::string f() { return {}; }
> > >
> > > I get
> > >
> > >     % clang++ -fsyntax-only foo.cpp --std=c++11
> > >     In file included from foo.cpp:1:
> > >     ./foo.hpp:1:1: error: use of undeclared identifier 'std'
> > >     std::string f();
> > >     ^
> > >     1 error generated.
> > >
> > > Swapping the include order makes this pass as `#include` is just
> textual
> > > replacement, and the `#include <string>` in `foo.cpp` would declare the
> > > symbol used in `foo.hpp`.
> > >
> > >
> > > Cheers,
> > >
> > > Benjamin
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message