| | 19 | }}} |
| | 20 | |
| | 21 | === Headers === |
| | 22 | Keep your include dependencies in header files as little as possible. Whenever a class member is just a pointer or reference, the forward declaration is sufficient. To make that easier there exists a prerequisites file for each library, containing all the necessary forward declarations. These have to be kept up to date of course. |
| | 23 | Example for a header file include sequence. |
| | 24 | {{{ |
| | 25 | #include "MyLibraryPrereqs.h" |
| | 26 | |
| | 27 | #include <string> // std includes |
| | 28 | |
| | 29 | #include <OgrePrerequisites.h> // most external libraries have forward declaration files as well |
| | 30 | #include <OgreFrameListener.h> // only include this if you inherit from it or you don't use an object as pointer/reference |
| | 31 | |
| | 32 | #include "Projectile.h" // our own files, if necessary |
| | 33 | }}} |
| | 34 | Note: Never ever (!!!) write {{{using namespace blah;}}} in header files! (think about what it means a little bit) |
| | 35 | |
| | 36 | === Source files === |
| | 37 | Again, keep the dependencies short. However it is not that severe in source files.[br] |
| | 38 | To ensure that every header file can be compiled without additional header dependencies, include class header file first. |
| | 39 | Include sequence is for {{{MyClass}}}: |
| | 40 | {{{ |
| | 41 | #include "MyClass.h" |
| | 42 | |
| | 43 | #include <vector> // std headers |
| | 44 | #include <map> |
| | 45 | |
| | 46 | #include <OgreSceneManager.h> // external library headers |
| | 47 | |
| | 48 | #include "BaseObject.h" // our own header files |