工程大了,有很多的头文件,也要引用很多的库文件。
从我们学习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:<