Reputation: 2832
There was a highly rated response in a question about header ordering with the following suggestion:
Good practice: every .h file should have a .cpp that includes that .h first before anything else. This proves that any .h file can be put first.
Even if the header requires no implementation, you make a .cpp that just includes that .h file and nothing else.
Personally I've never had a problem with include ordering for headers that don't have a corresponding cpp file. What kinds of problems does this best practice prevent?
Upvotes: 0
Views: 1556
Reputation: 8232
One problem it solves is allowing the .h file to be linted (at least by my lint tools). Without a .cpp doing an include of an .h my template code gets skipped.
Upvotes: 0
Reputation: 59987
#ifndef
etc...Both these will ensure that the order will not matter.
Upvotes: 3