mesos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yan Xu <xuj...@apple.com>
Subject Re: Order of includes
Date Mon, 19 Dec 2016 07:49:03 GMT
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