1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __IRR_TYPES_H_INCLUDED__
\r
6 #define __IRR_TYPES_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
10 #if defined(__GNUC__)
\r
11 #include <limits.h> // for __WORDSIZE
\r
17 //! 8 bit unsigned variable.
\r
18 /** This is a typedef for unsigned char, it ensures portability of the engine. */
\r
19 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
20 typedef unsigned __int8 u8;
\r
22 typedef unsigned char u8;
\r
25 //! 8 bit signed variable.
\r
26 /** This is a typedef for signed char, it ensures portability of the engine. */
\r
27 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
30 typedef signed char s8;
\r
33 //! 8 bit character variable.
\r
34 /** This is a typedef for char, it ensures portability of the engine. */
\r
39 //! 16 bit unsigned variable.
\r
40 /** This is a typedef for unsigned short, it ensures portability of the engine. */
\r
41 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
42 typedef unsigned __int16 u16;
\r
44 typedef unsigned short u16;
\r
47 //! 16 bit signed variable.
\r
48 /** This is a typedef for signed short, it ensures portability of the engine. */
\r
49 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
50 typedef __int16 s16;
\r
52 typedef signed short s16;
\r
57 //! 32 bit unsigned variable.
\r
58 /** This is a typedef for unsigned int, it ensures portability of the engine. */
\r
59 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
60 typedef unsigned __int32 u32;
\r
62 typedef unsigned int u32;
\r
65 //! 32 bit signed variable.
\r
66 /** This is a typedef for signed int, it ensures portability of the engine. */
\r
67 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
68 typedef __int32 s32;
\r
70 typedef signed int s32;
\r
74 #ifdef __IRR_HAS_S64
\r
75 //! 64 bit unsigned variable.
\r
76 /** This is a typedef for 64bit uint, it ensures portability of the engine. */
\r
77 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
78 typedef unsigned __int64 u64;
\r
79 #elif defined(__GNUC__)
\r
80 #if defined(__WORDSIZE) && __WORDSIZE == 64
\r
81 typedef unsigned long int u64;
\r
83 __extension__ typedef unsigned long long u64;
\r
86 typedef unsigned long long u64;
\r
89 //! 64 bit signed variable.
\r
90 /** This is a typedef for 64bit int, it ensures portability of the engine. */
\r
91 #if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
\r
92 typedef __int64 s64;
\r
93 #elif defined(__GNUC__)
\r
94 #if defined(__WORDSIZE) && __WORDSIZE == 64
\r
95 typedef long int s64;
\r
97 __extension__ typedef long long s64;
\r
100 typedef long long s64;
\r
102 #endif // __IRR_HAS_S64
\r
106 //! 32 bit floating point variable.
\r
107 /** This is a typedef for float, it ensures portability of the engine. */
\r
110 //! 64 bit floating point variable.
\r
111 /** This is a typedef for double, it ensures portability of the engine. */
\r
112 typedef double f64;
\r
115 } // end namespace irr
\r
119 #ifdef _IRR_WINDOWS_API_
\r
120 //! Defines for s{w,n}printf_irr because s{w,n}printf methods do not match the ISO C
\r
121 //! standard on Windows platforms.
\r
122 //! We want int snprintf_irr(char *str, size_t size, const char *format, ...);
\r
123 //! and int swprintf_irr(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
\r
124 #if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
\r
125 #define swprintf_irr swprintf_s
\r
126 #define snprintf_irr sprintf_s
\r
127 #elif !defined(__CYGWIN__)
\r
128 #define swprintf_irr _snwprintf
\r
129 #define snprintf_irr _snprintf
\r
132 // define the wchar_t type if not already built in.
\r
134 #ifndef _WCHAR_T_DEFINED
\r
135 //! A 16 bit wide character type.
\r
137 Defines the wchar_t-type.
\r
138 In VS6, its not possible to tell
\r
139 the standard compiler to treat wchar_t as a built-in type, and
\r
140 sometimes we just don't want to include the huge stdlib.h or wchar.h,
\r
143 typedef unsigned short wchar_t;
\r
144 #define _WCHAR_T_DEFINED
\r
145 #endif // wchar is not defined
\r
146 #endif // microsoft compiler
\r
148 #define swprintf_irr swprintf
\r
149 #define snprintf_irr snprintf
\r
150 #endif // _IRR_WINDOWS_API_
\r
155 //! Type name for character type used by the file system.
\r
156 /** Should the wide character version of the FileSystem be used it is a
\r
157 16 bit character variable. Used for Unicode Filesystem and Unicode strings.
\r
158 Else it is a 8 bit character variable. Used for ansi Filesystem and non-unicode
\r
161 #if defined(_IRR_WCHAR_FILESYSTEM)
\r
162 typedef wchar_t fschar_t;
\r
163 #define _IRR_TEXT(X) L##X
\r
165 typedef char fschar_t;
\r
166 #define _IRR_TEXT(X) X
\r
169 } // end namespace irr
\r
171 //! define a break macro for debugging.
\r
172 #if defined(_DEBUG)
\r
173 #if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && !defined (_WIN32_WCE)
\r
174 #if defined(WIN64) || defined(_WIN64) // using portable common solution for x64 configuration
\r
175 #include <crtdbg.h>
\r
176 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();}
\r
178 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
\r
181 #include "assert.h"
\r
182 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) );
\r
185 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
\r
188 //! Defines a deprecated macro which generates a warning at compile time
\r
189 /** The usage is simple
\r
190 For typedef: typedef _IRR_DEPRECATED_ int test1;
\r
191 For classes/structs: class _IRR_DEPRECATED_ test2 { ... };
\r
192 For methods: class test3 { _IRR_DEPRECATED_ virtual void foo() {} };
\r
193 For functions: template<class T> _IRR_DEPRECATED_ void test4(void) {}
\r
195 #if defined(IGNORE_DEPRECATED_WARNING)
\r
196 #define _IRR_DEPRECATED_
\r
197 #elif _MSC_VER >= 1310 //vs 2003 or higher
\r
198 #define _IRR_DEPRECATED_ __declspec(deprecated)
\r
199 #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // all versions above 3.0 should support this feature
\r
200 #define _IRR_DEPRECATED_ __attribute__ ((deprecated))
\r
202 #define _IRR_DEPRECATED_
\r
205 //! Defines an override macro, to protect virtual functions from typos and other mismatches
\r
206 /** Usage in a derived class:
\r
207 virtual void somefunc() _IRR_OVERRIDE_;
\r
209 #if ( ((__GNUC__ > 4 ) || ((__GNUC__ == 4 ) && (__GNUC_MINOR__ >= 7))) && (defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L) )
\r
210 #define _IRR_OVERRIDE_ override
\r
211 #elif (_MSC_VER >= 1600 ) /* supported since MSVC 2010 */
\r
212 #define _IRR_OVERRIDE_ override
\r
213 #elif (__clang_major__ >= 3 && __has_feature(cxx_override_control))
\r
214 #define _IRR_OVERRIDE_ override
\r
216 #define _IRR_OVERRIDE_
\r
219 // memory debugging
\r
220 #if defined(_DEBUG) && defined(IRRLICHT_EXPORTS) && defined(_MSC_VER) && \
\r
221 (_MSC_VER > 1299) && !defined(_IRR_DONT_DO_MEMORY_DEBUGGING_HERE) && !defined(_WIN32_WCE)
\r
223 #define CRTDBG_MAP_ALLOC
\r
224 #define _CRTDBG_MAP_ALLOC
\r
225 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
\r
226 #include <stdlib.h>
\r
227 #include <crtdbg.h>
\r
228 #define new DEBUG_CLIENTBLOCK
\r
231 //! ignore VC8 warning deprecated
\r
232 /** The Microsoft compiler */
\r
233 #if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER >= 1400)
\r
234 //#pragma warning( disable: 4996)
\r
235 //#define _CRT_SECURE_NO_DEPRECATE 1
\r
236 //#define _CRT_NONSTDC_NO_DEPRECATE 1
\r
240 //! creates four CC codes used in Irrlicht for simple ids
\r
241 /** some compilers can create those by directly writing the
\r
242 code like 'code', but some generate warnings so we use this macro here */
\r
243 #define MAKE_IRR_ID(c0, c1, c2, c3) \
\r
244 ((irr::u32)(irr::u8)(c0) | ((irr::u32)(irr::u8)(c1) << 8) | \
\r
245 ((irr::u32)(irr::u8)(c2) << 16) | ((irr::u32)(irr::u8)(c3) << 24 ))
\r
247 #endif // __IRR_TYPES_H_INCLUDED__
\r