Search CTRL + K

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).


  1. https://www.learncpp.com/cpp-tutorial/header-files/ ↩︎