> On Nov. 8, 2016, 8:38 a.m., Qian Zhang wrote: > > I do not quite understand the intention of this patch. The description of > > this patch says that `Previously, the headers did not contain includes for > > any of the classes used in the file.`, but actually `stout/os.hpp` has been > > already included which almost has all the needed headers, like > > `stout/nothing.hpp`, `stout/try.hpp`, etc. So I guess the intention of this > > patch is to remove the inclusion of `stout/os.hpp` and instead include each > > needed headers directly, right? But I still see `stout/os.hpp` in both > > `utils.hpp` and `utils.cpp` in this patch which makes me a bit confused. > > Joseph Wu wrote: > The style for our include headers is to include all dependencies, so that > changing the include headers of a dependency does not break any upstream code. > > i.e. > foo.hpp: > ``` > #include <string> > > typedef std::string Fooo; > ``` > > bar.hpp: > ``` > #include <map> > #include <string> // <- Need this because we use it in this file. > > #include "foo.hpp" > > std::map<Fooo, std::string> bar; > ``` > > The exception is any headers that are effectively aliases to other > headers, like `stout/lambda.hpp` (to various `<functional>` types) or > `src/messages/messages.hpp` (to the protobuf `messages.pb.h`).
Thanks for the explanation! So if a header is needed by `utils.cpp`, then `utils.cpp` should always include it even it has already been included in `utils.hpp`. And I have a further comment: in your updated patch, I see in `utils.cpp`, you include `stout/os.hpp` and also `stout/try.hpp`, `stout/nothing.hpp`, etc. which are actually already included in `stout/os.hpp`. I think that is not what we are doing in Mesos, if we have included `stout/os.hpp` in a .cpp, we do not need to include the header files in it again. See the following code as examples: https://github.com/apache/mesos/blob/1.0.1/src/slave/containerizer/mesos/provisioner/backend.cpp#L19 https://github.com/apache/mesos/blob/1.0.1/src/slave/containerizer/docker.cpp#L38 Both of the above two files use `Try` and `Nothing`, but they only include `stout/os.hpp` not `stout/try.hpp` and `stout/nothing.hpp`. - Qian ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/53556/#review155230 ----------------------------------------------------------- On Nov. 8, 2016, 8:56 a.m., Joseph Wu wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/53556/ > ----------------------------------------------------------- > > (Updated Nov. 8, 2016, 8:56 a.m.) > > > Review request for mesos, Benjamin Bannier, Jie Yu, and Qian Zhang. > > > Bugs: MESOS-6360 > https://issues.apache.org/jira/browse/MESOS-6360 > > > Repository: mesos > > > Description > ------- > > This fixes the headers in the provisioner utility. Previously, the > headers did not contain includes for any of the classes used in the > file. > > > Diffs > ----- > > src/slave/containerizer/mesos/provisioner/utils.hpp > 4efce0ed67312417495af8c884ce26ef6affaccb > src/slave/containerizer/mesos/provisioner/utils.cpp > 340cf48819679cdd8d08d76dcd2328234477a15f > > Diff: https://reviews.apache.org/r/53556/diff/ > > > Testing > ------- > > make check (OSX) > make check (CentOS 7) > msbuild ... (Windows 10) > > > Thanks, > > Joseph Wu > >
