Replies: 1 comment 1 reply
-
Unless I'm missing something, Google's C++ Style Guide does not recommend the order you describe. In fact, it recommends using the one we have today: https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes The main issues as I see in changing this at this point are two:
Besides, it it not very evident to me how this would benefit the project. I wonder what others think. Cc: @mbasmanova @majetideepak @xiaoxmeng @Yuhta @bikramSingh91 @duanmeng |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently the Velox code guidelines state the following order for include headers groups
However, I read many discussions about include orders online, e.g. https://stackoverflow.com/questions/2762568/c-c-include-header-file-order https://blog.knatten.org/2010/07/01/the-order-of-include-directives-matter/ and found the common practice is to have local to global order:
The main reason is to avoid hidden dependencies. E.g. if myclass.cpp includes then "myclass.h", there's no way to catch at build time that myclass.h may itself depend on string; so if later onsomeone includes myclass.h but don't need string, he will get an error that needs to be fixed either in the cpp or in the header itself. This is well explained in https://blog.knatten.org/2010/07/01/the-order-of-include-directives-matter/.
As someone mentioned in the StackOverflow discussion, It was also mentioned in "Thinking in C++" referencing Lakos' "Large Scale C++ Software Design". Also Google C++ Style Guide recommends using this order.
I think these reasoning makes a lot of sense, so would suggest we follow the local->global order and update the coding guideline.
Beta Was this translation helpful? Give feedback.
All reactions