Reputation: 16242
I was playing with cpplint
and I got this warning:
Found C++ system header after other header. Should be: transpose_square.h, c system, c++ system, other.
The source is the Google Styleguide, that apparently says (said?)
1. associated .h/.hpp (if this is a .cpp file)
2. C system files
3. C++ system files
4. Other libraries' .h/.hpp files
5. Your project’s .h/.hpp files
Leaving aside 1.
, I honestly thought that the recommended order was exactly the opposite!
2. Your project’s .h/.hpp files
3. Other libraries' .h/.hpp files
4. C++ system files
5. C system files
So, basically the idea is to include the headers in the order of "increasing distance" from the current project, ending with the most basic libraries.
I don't remember where I took that from, but I remember the logic was to detect missing dependencies headers in related or in the same project.
I don't remember if there was more than just this.
For example, in this case, the order will be forgiving for text_processing_utilities.hpp
to have a missing #include<string>
even if it depends on it:
#include<string>
#include "text_processing_utilities.hpp"
My question is, is the Google Style guide for headers a good convention regarding the order of system headers? Is there a good reason for it?
Upvotes: 1
Views: 32