Pioneer
libs.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _LIBS_H
5 #define _LIBS_H
6 
7 #include <SDL.h>
8 #include <SDL_image.h>
9 #include <sigc++/sigc++.h>
10 #include <algorithm>
11 #include <cassert>
12 #include <cerrno>
13 #include <cfloat>
14 #include <cinttypes>
15 #include <cmath>
16 #include <cstdarg>
17 #include <cstdio>
18 #include <cstdlib>
19 #include <cstring>
20 #include <ctime>
21 #include <deque>
22 #include <limits>
23 #include <map>
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 #ifdef _WIN32
29 #include <malloc.h>
30 
31 #ifdef _MSC_VER
32 #pragma warning(disable : 4244) // "conversion from x to x: possible loss of data"
33 #pragma warning(disable : 4800) // int-to-bool "performance warning"
34 #pragma warning(disable : 4355) // 'this' used in base member initializer list
35 #pragma warning(disable : 4351) // new behavior [after vs2003!]: elements of array 'array' will be default initialized
36 #endif
37 
38 #ifndef __MINGW32__
39 #define strncasecmp _strnicmp
40 #define strcasecmp _stricmp
41 #endif
42 #endif
43 
44 #define SIZET_FMT "%zu"
45 
46 #include "fixed.h"
47 #include "matrix3x3.h"
48 #include "matrix4x4.h"
49 #include "vector2.h"
50 #include "vector3.h"
51 
52 #include "Aabb.h"
53 #include "Color.h"
54 #include "Random.h"
55 
56 #include "FloatComparison.h"
57 #include "RefCounted.h"
58 #include "SmartPtr.h"
59 
60 #include "profiler/Profiler.h"
61 
62 #ifdef NDEBUG
63 #define PiVerify(x) ((void)(x))
64 #else
65 #define PiVerify(x) assert(x)
66 #endif
67 
68 template <class T>
69 inline const T &Clamp(const T &x, const T &min, const T &max) { return x > max ? max : (x < min ? min : x); }
70 
71 inline constexpr double DEG2RAD(double x) { return x * (M_PI / 180.); }
72 inline constexpr float DEG2RAD(float x) { return x * (float(M_PI) / 180.f); }
73 inline constexpr double RAD2DEG(double x) { return x * (180. / M_PI); }
74 inline constexpr float RAD2DEG(float x) { return x * (180.f / float(M_PI)); }
75 
76 // from StackOverflow: http://stackoverflow.com/a/1500517/52251
77 // Q: "Compile time sizeof_array without using a macro"
78 template <typename T, size_t N>
79 char (&COUNTOF_Helper(T (&array)[N]))[N];
80 #define COUNTOF(array) (sizeof(COUNTOF_Helper(array)))
81 
82 #endif /* _LIBS_H */
char(& COUNTOF_Helper(T(&array)[N]))[N]
constexpr double DEG2RAD(double x)
Definition: libs.h:71
const T & Clamp(const T &x, const T &min, const T &max)
Definition: libs.h:69
constexpr double RAD2DEG(double x)
Definition: libs.h:73