Pyrogenesis  trunk
precompiled.h
Go to the documentation of this file.
1 /* Copyright (C) 2022 Wildfire Games.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 /*
24  * precompiled header. must be the first non-comment part of every
25  * source file (VC++ requirement).
26  */
27 
28 // some libraries have only a small number of source files, and the
29 // overhead of including loads of headers here outweighs the improvements to
30 // incremental rebuild performance.
31 // they can set MINIMAL_PCH to 1 so we include far fewer headers (but
32 // still do the global disabling of warnings and include config headers etc),
33 // or set it to 2 to remove STL headers too (precompiling STL helps performance
34 // in most non-tiny cases)
35 #ifndef MINIMAL_PCH
36 # define MINIMAL_PCH 0
37 #endif
38 
39 #include "lib/config.h" // CONFIG_ENABLE_BOOST, CONFIG_ENABLE_PCH
40 #include "lib/sysdep/compiler.h" // MSC_VERSION
41 
42 // must come before any STL headers are included
43 #if MSC_VERSION
44 # if MSC_VERSION < 1910
45 # error "Visual Studio 2017 is the minimal supported version"
46 # endif
47 # ifdef NDEBUG // release: disable all checks
48 # define _HAS_ITERATOR_DEBUGGING 0
49 # define _SECURE_SCL 0
50 # endif
51 #endif
52 
53 // disable some common and annoying warnings
54 // (as soon as possible so that headers below are covered)
55 #include "lib/pch/pch_warnings.h"
56 
57 #if ICC_VERSION
58 #include <mathimf.h> // (must come before <cmath> or <math.h> (replaces them))
59 double __cdecl abs(double x); // not declared by mathimf
60 #endif
61 
62 
63 //
64 // headers made available everywhere for convenience
65 //
66 
67 #include "lib/posix/posix_types.h" // (must come before any system headers because it fixes off_t)
68 #include "lib/code_annotation.h"
69 #include "lib/sysdep/arch.h"
70 #include "lib/sysdep/os.h"
71 #include "lib/sysdep/stl.h"
72 #include "lib/types.h"
73 #include "lib/debug.h"
74 #include "lib/lib.h"
75 #include "lib/secure_crt.h"
76 
77 #if CONFIG_ENABLE_BOOST
78 # include "lib/pch/pch_boost.h"
79 #endif
80 
81 #include <array>
82 #include <memory>
83 
84 // (must come after boost and common lib headers, but before re-enabling
85 // warnings to avoid boost spew)
86 #include "lib/posix/posix.h"
87 
88 
89 //
90 // precompiled headers
91 //
92 
93 // if PCHs are supported and enabled, we make an effort to include all
94 // system headers. otherwise, only a few central headers (e.g. types)
95 // are pulled in and source files must include all the system headers
96 // they use. this policy ensures good compile performance whether or not
97 // PCHs are being used.
98 
99 #if CONFIG_ENABLE_PCH
100 
101 // anything placed here won't need to be compiled in each translation unit,
102 // but will cause a complete rebuild if they change.
103 
104 #include "lib/pch/pch_stdlib.h"
105 
106 // These two files are included (directly or indirectly) by about half of the .cpp files.
107 // Changing these thus forces recompilation of most of the project regardless,
108 // and putting them in the precompiled header cuts a large amount of time even even on incremental builds.
109 #include "ps/CLogger.h"
110 #include "ps/Profile.h"
111 
112 #endif // #if CONFIG_ENABLE_PCH