sbgDefines.h
Go to the documentation of this file.
1 
20 #ifndef __SBG_DEFINES_H__
21 #define __SBG_DEFINES_H__
22 
23 //----------------------------------------------------------------------//
24 //- Global definitions -//
25 //----------------------------------------------------------------------//
26 #ifndef SBG_DISABLE
27  #define SBG_DISABLE (0)
28 #endif
29 
30 #ifndef SBG_ENABLE
31  #define SBG_ENABLE (1)
32 #endif
33 
34 #ifndef FALSE
35  #define FALSE (0)
36 #endif
37 
38 #ifndef TRUE
39  #define TRUE (1)
40 #endif
41 
42 #ifndef NULL
43  #define NULL (0)
44 #endif
45 
46 #ifndef SBG_INVALID_HANDLE
47  #define SBG_INVALID_HANDLE (0x00000000u)
48 #endif
49 
50 #ifndef SBG_NOT_FOUND
51  #define SBG_NOT_FOUND (0xFFFFFFFFu)
52 #endif
53 
54 #ifndef SBG_UNDEFINED
55  #define SBG_UNDEFINED (0xFFFFFFFFu)
56 #endif
57 
58 #ifndef SBG_ARRAY_SIZE
59  #define SBG_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
60 #endif
61 
65 #ifndef __GNUC__
66 #ifndef __BASE_FILE__
67  #define __BASE_FILE__ __FILE__
68 #endif
69 #endif
70 
71 #ifdef __cplusplus
72  #define SBG_DELETE(p) if (p){delete (p); (p) = NULL;}
73  #define SBG_DELETE_ARRAY(p) if (p){delete[] (p); (p) = NULL;}
74  #define SBG_FREE(p) if (p){free(p); (p) = NULL;}
75  #define SBG_FREE_ARRAY(p) if (p){free(p); (p) = NULL;}
76 #else
77  #define SBG_DELETE if (p){free(p); (p) = NULL;}
78  #define SBG_DELETE_ARRAY if (p){free(p); (p) = NULL;}
79  #define SBG_FREE(p) if (p){free(p); (p) = NULL;}
80  #define SBG_FREE_ARRAY(p) if (p){free(p); (p) = NULL;}
81 #endif
82 
83 //----------------------------------------------------------------------//
84 //- Compiller definitions -//
85 //----------------------------------------------------------------------//
86 
90 #ifndef SBG_INLINE
91  #if defined(_WIN32) || defined(WIN32)
92  #define SBG_INLINE __inline
93  #else
94  #define SBG_INLINE static inline
95  #endif
96 #endif
97 
101 #ifndef SBG_UNUSED_PARAMETER
102  #define SBG_UNUSED_PARAMETER(x) (void)(x)
103 #endif
104 
105 //----------------------------------------------------------------------//
106 //- Macro used to defined packed structures -//
107 //----------------------------------------------------------------------//
108 
113 #ifdef __GNUC__
114  #define SBG_BEGIN_PACKED()
115 #elif defined(_MSC_VER)
116  #define SBG_BEGIN_PACKED() __pragma(pack(push, 1))
117 #else
118  #error you must byte-align these structures with the appropriate compiler directives
119 #endif
120 
124 #ifdef __GNUC__
125  #define SBG_PACKED __attribute__((packed))
126 #elif defined(_MSC_VER)
127  #define SBG_PACKED
128 #else
129  #error you must byte-align these structures with the appropriate compiler directives
130 #endif
131 
135 #ifdef __GNUC__
136  #define SBG_END_PACKED()
137 #elif defined(_MSC_VER)
138  #define SBG_END_PACKED() __pragma(pack(pop))
139 #else
140  #error you must byte-align these structures with the appropriate compiler directives
141 #endif
142 
143 //----------------------------------------------------------------------//
144 //- Deprecation definitions -//
145 //----------------------------------------------------------------------//
146 
150 #ifdef __GNUC__
151  #define SBG_DEPRECATED(func) func __attribute__ ((deprecated))
152 #elif defined(_MSC_VER)
153  #define SBG_DEPRECATED(func) __declspec(deprecated) func
154 #else
155  //#warning "WARNING: You need to implement SBG_DEPRECATED for this compiler"
156  #define SBG_DEPRECATED(func) func
157 #endif
158 
162 #ifdef __GNUC__
163  #define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func))
164 #elif defined(_MSC_VER)
165 #define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func))
166 #else
167  //#warning "WARNING: You need to implement SBG_DEPRECATED_MACRO for this compiler"
168  #define SBG_DEPRECATED_MACRO(func) func
169 #endif
170 
171 //----------------------------------------------------------------------//
172 //- Basic maths definitions -//
173 //----------------------------------------------------------------------//
174 #ifndef SBG_PI
175  #define SBG_PI 3.14159265358979323846
176 #endif
177 
178 #ifndef SBG_PI_F
179  #define SBG_PI_F 3.14159265358979323846f
180 #endif
181 
188 #ifndef sbgMax
189  #define sbgMax(a,b) (((a) > (b)) ? (a) : (b))
190 #endif
191 
198 #ifndef sbgMin
199  #define sbgMin(a,b) (((a) < (b)) ? (a) : (b))
200 #endif
201 
209 #ifndef sbgClamp
210  #define sbgClamp(value, minValue, maxValue) (((value) < (minValue))?(minValue): ((value) > (maxValue)?maxValue:value))
211 #endif
212 
218 SBG_INLINE double sbgRadToDegD(double angle)
219 {
220  return angle * 180.0 / SBG_PI;
221 }
222 
228 SBG_INLINE double sbgDegToRadD(double angle)
229 {
230  return angle * SBG_PI / 180.0;
231 }
232 
238 SBG_INLINE float sbgRadToDegF(float angle)
239 {
240  return angle * 180.0f / SBG_PI_F;
241 }
242 
248 SBG_INLINE float sbgDegToRadF(float angle)
249 {
250  return angle * SBG_PI_F / 180.0f;
251 }
252 
253 #endif /* __SBG_DEFINES_H__ */
SBG_INLINE float sbgRadToDegF(float angle)
Definition: sbgDefines.h:238
SBG_INLINE float sbgDegToRadF(float angle)
Definition: sbgDefines.h:248
SBG_INLINE double sbgRadToDegD(double angle)
Definition: sbgDefines.h:218
SBG_INLINE double sbgDegToRadD(double angle)
Definition: sbgDefines.h:228
#define SBG_PI
Definition: sbgDefines.h:175
#define SBG_INLINE
Definition: sbgDefines.h:94
#define SBG_PI_F
Definition: sbgDefines.h:179


sbg_driver
Author(s):
autogenerated on Sun Jan 27 2019 03:42:20