VS2015--win32工程配置的一些想法之Google Code Style中头文件的顺序
2016-02-23 13:29:45 】 浏览:1018次 本网站的内容取自网络,仅供学习参考之用,绝无侵犯任何人知识产权之意。如有侵犯请您及时与本人取得联系,万分感谢。
Tags:VS2015--win32 工程 配置 一些 想法 Google Code Style 文件 顺序

从我们学习C++写hello world的那一刻起,就知道要包含一些系统文件。


看看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/ or dir/, 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/ and dir2/foo2.h are often in the same directory (e.g. base/ 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/ might look like this:

#include "foo/public/fooserver.h"  // Preferred location.

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


#include a.h

      #include "base/base.h"


VS2015--win32工程配置的一些想法之Google Code Style中头文件的顺序

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇VS2015--win32工程配置的一些想法.. 下一篇VS2015--win32工程配置的一些想法..


验 证 码:
表  情:
内  容: