Include Order
在 cpp 中,引用头文件时建议以如下顺序:
- 对应的头文件
- 项目中其他头文件
- 第三方库头文件
- 标准库头文件
Best practice of include order of header files
To maximize the chance that missing includes will be flagged by compiler, order your #includes as follows:[1]
- The paired header file
- Other headers from your project
- 3rd party library headers
- Standard library headers
The headers for each grouping should be sorted alphabetically (unless the documentation for a 3rd party library instructs you to do otherwise).