ManaPlus
localconsts.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2018 The ManaPlus Developers
4  *
5  * This file is part of The ManaPlus Client.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef LOCALCONSTS_H
22 #define LOCALCONSTS_H
23 
24 #define ENABLEDEBUGLOG 1
25 
26 #ifndef GCC_VERSION
27 #define GCC_VERSION (__GNUC__ * 10000 \
28  + __GNUC_MINOR__ * 100 \
29  + __GNUC_PATCHLEVEL__)
30 #endif // GCC_VERSION
31 
32 #ifdef __clang__
33 #ifndef CLANG_VERSION
34 #define CLANG_VERSION (__clang_major__ * 10000 \
35  + __clang_minor__ * 100 \
36  + __clang_patchlevel__)
37 #endif // CLANG_VERSION
38 #endif // __clang__
39 
40 #define A_DEFAULT_COPY(func)
41 
42 #if !defined(__GXX_EXPERIMENTAL_CXX0X__)
43 #undef nullptr
44 #define nullptr 0
45 #define final
46 #define override
47 #define constexpr
48 #define constexpr2
49 #define noexcept2
50 #define noexcept
51 #define A_DELETE(func)
52 #define A_DELETE_COPY(func)
53 #else // !defined(__GXX_EXPERIMENTAL_CXX0X__)
54 #if GCC_VERSION < 40700
55 
56 #if defined(__clang__) && __cplusplus > 201100L
57 #else // __clang__
58 #define final
59 #define override
60 #define constexpr
61 #define noexcept
62 #endif // __clang__
63 #define noexcept2
64 #define constexpr2
65 
66 // #define A_DELETE
67 // #define A_DELETE_COPY
68 #else // GCC_VERSION < 40700
69 #define ADVGCC
70 #if GCC_VERSION < 40900
71 #define constexpr2
72 #define noexcept2
73 #else // GCC_VERSION < 40900
74 #if __cpp_constexpr >= 201304
75 #define constexpr2 constexpr
76 #else // __cpp_constexpr >= 201304
77 #define constexpr2
78 #endif // __cpp_constexpr >= 201304
79 
80 #ifdef __clang__
81 #define noexcept2
82 #else // __clang__
83 #define noexcept2 noexcept
84 #endif // __clang__
85 
86 #endif // GCC_VERSION < 40900
87 #endif // GCC_VERSION < 40700
88 #define M_TCPOK
89 #define A_DELETE(func) func = delete
90 #define A_DELETE_COPY(name) name(const name &) = delete; \
91  name &operator=(const name&) = delete;
92 #endif // !defined(__GXX_EXPERIMENTAL_CXX0X__)
93 
94 #ifdef __clang__
95 #define constexpr3
96 #elif GCC_VERSION > 70000
97 #define constexpr3 constexpr
98 #else
99 #define constexpr3
100 #endif
101 
102 #ifdef __GNUC__
103 #define A_UNUSED __attribute__ ((unused))
104 #define A_WARN_UNUSED __attribute__ ((warn_unused_result))
105 #ifdef UNITTESTS
106 #define A_WARN_UNUSED_NON_TESTS
107 #else // UNITTESTS
108 #define A_WARN_UNUSED_NON_TESTS __attribute__ ((warn_unused_result))
109 #endif // UNITTESTS
110 #define DEPRECATED __attribute__ ((deprecated))
111 #ifdef DYECMD
112 #define A_DYECMD_UNUSED __attribute__ ((unused))
113 #else // DYECMD
114 #define A_DYECMD_UNUSED
115 #endif // DYECMD
116 
117 #ifdef __native_client__
118 #define restrict
119 #define restrict2
120 #else // __native_client__
121 #ifdef __clang__
122 // because restrict broken in clang, now it removed from all places.
123 // #define restrict __restrict__
124 #define restrict
125 #define restrict2
126 #else // __clang__
127 #define restrict __restrict__
128 #define restrict2 __restrict__
129 #endif // __clang__
130 #endif // __native_client__
131 
132 #define A_CONST __attribute__ ((const))
133 #define A_PURE __attribute__ ((pure))
134 #define A_INLINE __attribute__ ((always_inline))
135 
136 #ifdef __x86_64__
137 // gcc 4.8 look like support avx2, but need global define for enable any SIMD
138 #if GCC_VERSION >= 40900
139 #define SIMD_SUPPORTED
140 #endif // GCC_VERSION > 40900
141 #if defined(__clang__) && CLANG_VERSION >= 30800
142 #define SIMD_SUPPORTED
143 #endif // defined(__clang__) && CLANG_VERSION >= 30800
144 #endif // __x86_64__
145 
146 #ifdef __INTEL_COMPILER
147 #define RETURNS_NONNULL
148 #else // __INTEL_COMPILER
149 #if GCC_VERSION < 40900
150 #define RETURNS_NONNULL
151 #else // GCC_VERSION < 40900
152 #define RETURNS_NONNULL __attribute__((returns_nonnull))
153 #endif // GCC_VERSION < 40900
154 #endif // __INTEL_COMPILER
155 
156 #define A_NONNULL(...) __attribute__((nonnull (__VA_ARGS__)))
157 
158 #else // __GNUC__
159 #define A_UNUSED
160 #define A_WARN_UNUSED
161 #define A_WARN_UNUSED_NON_TESTS
162 #define gnu_printf printf
163 #define DEPRECATED
164 #define restrict
165 #define restrict2
166 #define RETURNS_NONNULL
167 #define A_NONNULL(...)
168 #endif // __GNUC__
169 #ifdef __clang__
170 #define gnu_printf printf
171 #endif // __clang__
172 
173 #ifdef ADVGCC
174 
175 #define const2 const
176 
177 #if GCC_VERSION >= 60000
178 #define PRAGMA6(str) _Pragma(#str)
179 #else // GCC_VERSION > 60000
180 #define PRAGMA6(str)
181 #endif // GCC_VERSION > 60000
182 
183 #if GCC_VERSION >= 70000
184 #define A_FALLTHROUGH __attribute__ ((fallthrough));
185 #else // GCC_VERSION > 70000
186 #define A_FALLTHROUGH
187 #endif // GCC_VERSION > 70000
188 
189 #else // ADVGCC
190 #define const2
191 #define PRAGMA6(str)
192 #define A_FALLTHROUGH
193 #endif // ADVGCC
194 
195 #if GCC_VERSION >= 48000
196 #define PRAGMA48(str) _Pragma(#str)
197 #else // GCC_VERSION > 48000
198 #define PRAGMA48(str)
199 #endif // GCC_VERSION > 48000
200 
201 #if GCC_VERSION >= 49000
202 #define PRAGMA49(str) _Pragma(#str)
203 #else // GCC_VERSION > 49000
204 #define PRAGMA49(str)
205 #endif // GCC_VERSION > 49000
206 
207 #if GCC_VERSION >= 80000
208 #define PRAGMA8(str) _Pragma(#str)
209 #else // GCC_VERSION > 80000
210 #define PRAGMA8(str)
211 #endif // GCC_VERSION > 80000
212 
213 #ifdef __clang__
214 #define PRAGMACLANG(str) _Pragma(#str)
215 #if CLANG_VERSION >= 50000
216 #define PRAGMACLANG5(str) _Pragma(#str)
217 #else // CLANG_VERSION >= 50000
218 #define PRAGMACLANG5(str)
219 #endif // CLANG_VERSION >= 50000
220 #if CLANG_VERSION >= 30800
221 #define PRAGMACLANG6(str) _Pragma(#str)
222 #define CLANG_FALLTHROUGH [[clang::fallthrough]];
223 #else // __clang_major__ >= 6
224 #define PRAGMACLANG6(str)
225 #define CLANG_FALLTHROUGH
226 #endif // __clang_major__ >= 6
227 #else // __clang__
228 #define PRAGMACLANG(str)
229 #define PRAGMACLANG5(str)
230 #define PRAGMACLANG6(str)
231 #define CLANG_FALLTHROUGH
232 #endif // __clang__
233 
234 #if GCC_VERSION >= 40600
235 #define PRAGMACLANG6GCC(str) _Pragma(#str)
236 #elif defined(__clang__) && CLANG_VERSION >= 30800
237 #define PRAGMACLANG6GCC(str) _Pragma(#str)
238 #else // __clang__
239 #define PRAGMACLANG6GCC(str)
240 #endif // __clang__
241 
242 #ifdef __GNUC__
243 #if GCC_VERSION >= 40600
244 #define PRAGMA45(str) _Pragma(#str)
245 #elif defined(__clang__)
246 #define PRAGMA45(str) _Pragma(#str)
247 #else // GCC_VERSION > 40600
248 #define PRAGMA45(str)
249 #endif // GCC_VERSION > 40600
250 
251 #if GCC_VERSION >= 40000
252 #define PRAGMA4(str) _Pragma(#str)
253 #elif defined(__clang__)
254 #define PRAGMA4(str) _Pragma(#str)
255 #else // GCC_VERSION > 40000
256 #define PRAGMA4(str)
257 #endif // GCC_VERSION > 40000
258 #endif // __GNUC__
259 
260 #define notfinal
261 
262 #ifdef ENABLE_CHECKPLUGIN
263 #define A_NONNULLPOINTER __attribute__((nonnullpointer))
264 #else // ENABLE_CHECKPLUGIN
265 #define A_NONNULLPOINTER
266 #endif // ENABLE_CHECKPLUGIN
267 
268 #ifdef ENABLE_CHECKS
269 
270 #define CHECKLISTENERS \
271  config.checkListeners(this, __FILE__, __LINE__); \
272  serverConfig.checkListeners(this, __FILE__, __LINE__);
273 
274 #else // ENABLE_CHECKS
275 
276 #define CHECKLISTENERS
277 
278 #endif // ENABLE_CHECKS
279 
280 #if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
281 #define ifconstexpr if constexpr
282 #else // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
283 #define ifconstexpr if
284 #endif // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
285 
286 #ifdef USE_SDL2
287 PRAGMA45(GCC diagnostic push)
288 PRAGMA45(GCC diagnostic ignored "-Wswitch-default")
289 #endif // USE_SDL2
290 PRAGMA48(GCC diagnostic push)
291 PRAGMA48(GCC diagnostic ignored "-Wshadow")
292 #include <SDL_version.h>
293 PRAGMA48(GCC diagnostic pop)
294 #ifdef USE_SDL2
295 PRAGMA45(GCC diagnostic pop)
296 #endif // USE_SDL2
297 
298 #if SDL_VERSION_ATLEAST(2, 0, 0)
299 #ifndef USE_SDL2
300 #warning using SDL2 headers but configure set to use SDL1.2
301 #warning please add configure flag --with-sdl2
302 #define USE_SDL2
303 #endif // USE_SDL2
304 #else // SDL_VERSION_ATLEAST(2, 0, 0)
305 #ifdef USE_SDL2
306 #error using SDL1.2 headers but configure set to use SDL2
307 #error please remove configure flag --with-sdl2
308 #endif // USE_SDL2
309 #endif // SDL_VERSION_ATLEAST(2, 0, 0)
310 
311 // #define DEBUG_CONFIG 1
312 // #define DEBUG_BIND_TEXTURE 1
313 // #define DISABLE_RESOURCE_CACHING 1
314 #define DUMP_LEAKED_RESOURCES 1
315 // #define DEBUG_DUMP_LEAKS1 1
316 // #define DEBUG_SDLFONT 1
317 
318 // android or nacl logging
319 // #define SPECIAL_LOGGING 1
320 
321 // profiler
322 // #define USE_PROFILER 1
323 
324 // draw calls
325 // #define DEBUG_DRAW_CALLS 1
326 
327 // debug images usage
328 // #define DEBUG_IMAGES 1
329 
330 // debug SDL surfaces
331 // #define DEBUG_SDL_SURFACES 1
332 
333 // debug virtfs usage
334 // #define DEBUG_VIRTFS 1
335 
336 // use file access fuzzer
337 // #define USE_FUZZER 1
338 
339 // use OpenGL debug features
340 // #define DEBUG_OPENGL 1
341 
342 // debug animations
343 // #define DEBUG_ANIMATIONS 1
344 
345 #define USE_FILE_FOPEN 1
346 
347 #ifdef __MINGW32__
348 #define PRAGMAMINGW(str) _Pragma(#str)
349 #define A_WIN_UNUSED __attribute__ ((unused))
350 #else // __MINGW32__
351 #define PRAGMAMINGW(str)
352 #define A_WIN_UNUSED
353 #endif // __MINGW32__
354 
355 #ifdef DYECMD
356 #undef USE_FUZZER
357 #endif // DYECMD
358 #include "utils/perfomance.h"
359 UTILS_PERFOMANCE_H // guard for protect previous include
360 #ifdef HAVE_CONFIG_H
361 #include "config.h"
362 #endif // HAVE_CONFIG_H
363 
364 #endif // LOCALCONSTS_H
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
#define PRAGMA48(str)
Definition: localconsts.h:198