| 208 | === Preprocessor instructions === |
| 209 | |
| 210 | The `#include` instructions, placed after the license notice, should follow a consistent order (which is currently not the case). Between each section in the following list, we usually add an empty line. |
| 211 | |
| 212 | 1. The first non-comment line of **any** source file **must** be `#include "precompiled.h"` |
| 213 | 1. For `.cpp` files that contain function implementations, headers that declare those functions should be included here. For instance, `#include "Simulation2.h"` for `Simulation2.cpp`, or `#include "ICmpPosition.h"` for `CCmpPosition.cpp`. |
| 214 | 1. Include the files that come from the same folder. Do not write the complete path relative to `source/`, but rather the file name only. Use case-insensitive alphabetical order. |
| 215 | 1. Include the files that come from the same project, but a different folder (even subdirectories of the current file's directory). Write the complete path relative to `source/`, for instance `#include "simulation2/Simulation2.h"`. Use case-insensitive alphabetical order. |
| 216 | 1. Include the files that come from other projects. Write the complete path relative to `source/`, for instance `#include "lib/file/file.h"`. Use case-insensitive alphabetical order. |
| 217 | 1. Include system libraries, in case-insensitive alphabetical order. |
| 218 | |
| 219 | Example, for the file `source/simulation2/Simulation2.cpp` (this is not the actual list, but an example that should cover all cases): |
| 220 | |
| 221 | {{{ |
| 222 | #include "precompiled.h" |
| 223 | |
| 224 | #include "Simulation2.h" |
| 225 | |
| 226 | #include "Example.h" |
| 227 | #include "MessageTypes.h" |
| 228 | |
| 229 | #include "simulation2/components/ICmpAIManager.h" |
| 230 | #include "simulation2/components/ICmpCommandQueue.h" |
| 231 | #include "simulation2/components/ICmpTemplateManager.h" |
| 232 | #include "simulation2/system/ComponentManager.h" |
| 233 | #include "simulation2/system/ParamNode.h" |
| 234 | |
| 235 | #include "graphics/Terrain.h" |
| 236 | #include "lib/file/vfs/vfs_util.h" |
| 237 | #include "lib/timer.h" |
| 238 | #include "maths/MathUtil.h" |
| 239 | #include "ps/Loader.h" |
| 240 | #include "ps/lowercase.h" |
| 241 | #include "ps/Profile.h" |
| 242 | #include "ps/XML/Xeromyces.h" |
| 243 | #include "scriptinterface/ScriptInterface.h" |
| 244 | #include "scriptinterface/ScriptRuntime.h" |
| 245 | |
| 246 | #include <iomanip> |
| 247 | #include <string> |
| 248 | }}} |
| 249 | |