Right now there seems to be no rule on where to put your preprocessor directives (include files mostly). I'd like to get this figured out because its sort of messy to go looking around between header and source files see what is included in big projects. |
Only include a header file A.h within header file B.h if B.h uses a definition from A.h. What if
B.h
unnecessarily includes A.h, and B.h is included in B.cpp, X.cpp, Y.cpp, Z.cpp, AA.cpp, etc. If you make a change to A.h, then X.cpp, Y.cpp, Z.cpp, A.cpp, etc. will need to be recompiled for no reason. If only B.cpp requires the definitions within A.h, then put the #include "A.h" statement in B.cpp.
I don't know what you mean by a "big" project, but to me a "big project" can take hours to build. Placing your header files in other header files (when not needed there) can turn a 10 minute rebuild into a 2 hour lunch break.
So, the answer to your question is, put the header files as close to where they are needed as possible. Put them in the .cpp files unless they are needed in the header file.
Also, your compiler almost certainly has an option for producing a dependency list, so you don't have to trace through manually to figure out what is included in any particular compilation unit.