VS 2015-win 32エンジニアリング構成のいくつかの考え方Google Code Styleのヘッダファイルの順序


工事が大きくなって、頭のファイルがたくさんあって、たくさんのライブラリのファイルを引用します.私たちがC++を勉強してhello worldを書いた瞬間から、いくつかのシステムファイルが含まれていることが分かりました.
では、順番はどうですか.reviewの時、自分が書いたものが糞だと感じました.
Google code styleでincludeファイルの順序をどのように説明しているかを見てみましょう.
Names and Order of Includes Use standard order for readability and to avoid hidden dependencies: C library, C++ library, other libraries’ .h, your project’s .h.
All of a project’s header files should be listed as descendants of the project’s source directory without use of UNIX directory shortcuts . (the current directory) or .. (the parent directory). For example, google-awesome-project/src/base/logging.h should be included as
#include "base/logging.h"

In dir/foo.cc or dir/foo_test.cc, whose main purpose is to implement or test the stuff in dir2/foo2.h, order your includes as follows:
dir2/foo2.h (preferred location — see details below). C system files. C++ system files. Other libraries’ .h files. Your project’s .h files.
The preferred ordering reduces hidden dependencies. We want every header file to be compilable on its own. The easiest way to achieve this is to make sure that every one of them is the first .h file #included in some .cc.
dir/foo.cc and dir2/foo2.h are often in the same directory (e.g. base/basictypes_test.cc and base/basictypes.h), but can be in different directories too.
Within each section it is nice to order the includes alphabetically.
For example, the includes in google-awesome-project/src/foo/internal/fooserver.cc might look like this:
#include "foo/public/fooserver.h" // Preferred location.

#include <sys/types.h>
#include <unistd.h>

#include <hash_map>
#include <vector>

#include "base/basictypes.h"
#include "base/commandlineflags.h"
#include "foo/public/bar.h"

これは通俗的に言えば、あなたはa.hとa.ccを書いています.ccファイルには、baseフォルダの下にあるbaseに共通するものが必要です.h中.では、a.ccファイルには、次の順序が含まれています.
#include a.h

#include <sys/types.h> 

#include <algorithm>

#include "base/base.h"