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
14 //! 8 bit unsigned variable.
\r
17 //! 8 bit signed variable.
\r
20 //! 8 bit character variable.
\r
21 /** This is a typedef for char, it ensures portability of the engine. */
\r
26 //! 16 bit unsigned variable.
\r
27 typedef uint16_t u16;
\r
29 //! 16 bit signed variable.
\r
30 typedef int16_t s16;
\r
34 //! 32 bit unsigned variable.
\r
35 typedef uint32_t u32;
\r
37 //! 32 bit signed variable.
\r
38 typedef int32_t s32;
\r
41 #ifdef __IRR_HAS_S64
\r
42 //! 64 bit unsigned variable.
\r
43 typedef uint64_t u64;
\r
45 //! 64 bit signed variable.
\r
46 typedef int64_t s64;
\r
47 #endif // __IRR_HAS_S64
\r
51 //! 32 bit floating point variable.
\r
52 /** This is a typedef for float, it ensures portability of the engine. */
\r
55 //! 64 bit floating point variable.
\r
56 /** This is a typedef for double, it ensures portability of the engine. */
\r
60 } // end namespace irr
\r
64 #ifdef _IRR_WINDOWS_API_
\r
65 //! Defines for s{w,n}printf_irr because s{w,n}printf methods do not match the ISO C
\r
66 //! standard on Windows platforms.
\r
67 //! We want int snprintf_irr(char *str, size_t size, const char *format, ...);
\r
68 //! and int swprintf_irr(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
\r
69 #if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
\r
70 #define swprintf_irr swprintf_s
\r
71 #define snprintf_irr sprintf_s
\r
72 #elif !defined(__CYGWIN__)
\r
73 #define swprintf_irr _snwprintf
\r
74 #define snprintf_irr _snprintf
\r
77 // define the wchar_t type if not already built in.
\r
79 #ifndef _WCHAR_T_DEFINED
\r
80 //! A 16 bit wide character type.
\r
82 Defines the wchar_t-type.
\r
83 In VS6, its not possible to tell
\r
84 the standard compiler to treat wchar_t as a built-in type, and
\r
85 sometimes we just don't want to include the huge stdlib.h or wchar.h,
\r
88 typedef unsigned short wchar_t;
\r
89 #define _WCHAR_T_DEFINED
\r
90 #endif // wchar is not defined
\r
91 #endif // microsoft compiler
\r
93 #define swprintf_irr swprintf
\r
94 #define snprintf_irr snprintf
\r
95 #endif // _IRR_WINDOWS_API_
\r
100 //! Type name for character type used by the file system.
\r
101 /** Should the wide character version of the FileSystem be used it is a
\r
102 16 bit character variable. Used for Unicode Filesystem and Unicode strings.
\r
103 Else it is a 8 bit character variable. Used for ansi Filesystem and non-unicode
\r
106 #if defined(_IRR_WCHAR_FILESYSTEM)
\r
107 typedef wchar_t fschar_t;
\r
108 #define _IRR_TEXT(X) L##X
\r
110 typedef char fschar_t;
\r
111 #define _IRR_TEXT(X) X
\r
114 } // end namespace irr
\r
116 //! define a break macro for debugging.
\r
117 #if defined(_DEBUG)
\r
118 #if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && !defined (_WIN32_WCE)
\r
119 #if defined(WIN64) || defined(_WIN64) // using portable common solution for x64 configuration
\r
120 #include <crtdbg.h>
\r
121 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();}
\r
123 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
\r
126 #include "assert.h"
\r
127 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) );
\r
130 #define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
\r
133 //! Defines a deprecated macro which generates a warning at compile time
\r
134 /** The usage is simple
\r
135 For typedef: typedef _IRR_DEPRECATED_ int test1;
\r
136 For classes/structs: class _IRR_DEPRECATED_ test2 { ... };
\r
137 For methods: class test3 { _IRR_DEPRECATED_ virtual void foo() {} };
\r
138 For functions: template<class T> _IRR_DEPRECATED_ void test4(void) {}
\r
140 #if defined(IGNORE_DEPRECATED_WARNING)
\r
141 #define _IRR_DEPRECATED_
\r
142 #elif _MSC_VER >= 1310 //vs 2003 or higher
\r
143 #define _IRR_DEPRECATED_ __declspec(deprecated)
\r
144 #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // all versions above 3.0 should support this feature
\r
145 #define _IRR_DEPRECATED_ __attribute__ ((deprecated))
\r
147 #define _IRR_DEPRECATED_
\r
150 //! Defines an override macro, to protect virtual functions from typos and other mismatches
\r
151 /** Usage in a derived class:
\r
152 virtual void somefunc() _IRR_OVERRIDE_;
\r
154 #if ( ((__GNUC__ > 4 ) || ((__GNUC__ == 4 ) && (__GNUC_MINOR__ >= 7))) && (defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L) )
\r
155 #define _IRR_OVERRIDE_ override
\r
156 #elif (_MSC_VER >= 1600 ) /* supported since MSVC 2010 */
\r
157 #define _IRR_OVERRIDE_ override
\r
158 #elif (__clang_major__ >= 3 && __has_feature(cxx_override_control))
\r
159 #define _IRR_OVERRIDE_ override
\r
161 #define _IRR_OVERRIDE_
\r
164 // memory debugging
\r
165 #if defined(_DEBUG) && defined(IRRLICHT_EXPORTS) && defined(_MSC_VER) && \
\r
166 (_MSC_VER > 1299) && !defined(_IRR_DONT_DO_MEMORY_DEBUGGING_HERE) && !defined(_WIN32_WCE)
\r
168 #define CRTDBG_MAP_ALLOC
\r
169 #define _CRTDBG_MAP_ALLOC
\r
170 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
\r
171 #include <stdlib.h>
\r
172 #include <crtdbg.h>
\r
173 #define new DEBUG_CLIENTBLOCK
\r
176 //! ignore VC8 warning deprecated
\r
177 /** The Microsoft compiler */
\r
178 #if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER >= 1400)
\r
179 //#pragma warning( disable: 4996)
\r
180 //#define _CRT_SECURE_NO_DEPRECATE 1
\r
181 //#define _CRT_NONSTDC_NO_DEPRECATE 1
\r
185 //! creates four CC codes used in Irrlicht for simple ids
\r
186 /** some compilers can create those by directly writing the
\r
187 code like 'code', but some generate warnings so we use this macro here */
\r
188 #define MAKE_IRR_ID(c0, c1, c2, c3) \
\r
189 ((irr::u32)(irr::u8)(c0) | ((irr::u32)(irr::u8)(c1) << 8) | \
\r
190 ((irr::u32)(irr::u8)(c2) << 16) | ((irr::u32)(irr::u8)(c3) << 24 ))
\r
192 #endif // __IRR_TYPES_H_INCLUDED__
\r