]> git.lizzy.rs Git - irrlicht.git/blob - include/irrTypes.h
e67b3958abe5da29ddecee4188ed30de10ba1495
[irrlicht.git] / include / irrTypes.h
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
4 \r
5 #ifndef __IRR_TYPES_H_INCLUDED__\r
6 #define __IRR_TYPES_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 #include <stdint.h>\r
10 \r
11 namespace irr\r
12 {\r
13 \r
14 //! 8 bit unsigned variable.\r
15 typedef uint8_t                 u8;\r
16 \r
17 //! 8 bit signed variable.\r
18 typedef int8_t                  s8;\r
19 \r
20 //! 8 bit character variable.\r
21 /** This is a typedef for char, it ensures portability of the engine. */\r
22 typedef char                    c8;\r
23 \r
24 \r
25 \r
26 //! 16 bit unsigned variable.\r
27 typedef uint16_t                u16;\r
28 \r
29 //! 16 bit signed variable.\r
30 typedef int16_t                 s16;\r
31 \r
32 \r
33 \r
34 //! 32 bit unsigned variable.\r
35 typedef uint32_t                u32;\r
36 \r
37 //! 32 bit signed variable.\r
38 typedef int32_t                 s32;\r
39 \r
40 \r
41 #ifdef __IRR_HAS_S64\r
42 //! 64 bit unsigned variable.\r
43 typedef uint64_t                u64;\r
44 \r
45 //! 64 bit signed variable.\r
46 typedef int64_t                 s64;\r
47 #endif  // __IRR_HAS_S64\r
48 \r
49 \r
50 \r
51 //! 32 bit floating point variable.\r
52 /** This is a typedef for float, it ensures portability of the engine. */\r
53 typedef float                           f32;\r
54 \r
55 //! 64 bit floating point variable.\r
56 /** This is a typedef for double, it ensures portability of the engine. */\r
57 typedef double                          f64;\r
58 \r
59 \r
60 } // end namespace irr\r
61 \r
62 \r
63 #include <wchar.h>\r
64 //! Defines for s{w,n}printf_irr because s{w,n}printf methods do not match the ISO C\r
65 //! standard on Windows platforms.\r
66 //! We want int snprintf_irr(char *str, size_t size, const char *format, ...);\r
67 //! and int swprintf_irr(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);\r
68 #if defined(_MSC_VER)\r
69 #define swprintf_irr swprintf_s\r
70 #define snprintf_irr sprintf_s\r
71 #else\r
72 #define swprintf_irr swprintf\r
73 #define snprintf_irr snprintf\r
74 #endif // _MSC_VER\r
75 \r
76 namespace irr\r
77 {\r
78 \r
79 //! Type name for character type used by the file system.\r
80         typedef char fschar_t;\r
81         #define _IRR_TEXT(X) X\r
82 \r
83 } // end namespace irr\r
84 \r
85 //! define a break macro for debugging.\r
86 #if defined(_DEBUG)\r
87 #if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER)\r
88         #include <crtdbg.h>\r
89         #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();}\r
90 #else\r
91         #include <assert.h>\r
92         #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) );\r
93 #endif\r
94 #else\r
95         #define _IRR_DEBUG_BREAK_IF( _CONDITION_ )\r
96 #endif\r
97 \r
98 //! Defines a deprecated macro which generates a warning at compile time\r
99 /** The usage is simple\r
100 For typedef:            typedef _IRR_DEPRECATED_ int test1;\r
101 For classes/structs:    class _IRR_DEPRECATED_ test2 { ... };\r
102 For methods:            class test3 { _IRR_DEPRECATED_ virtual void foo() {} };\r
103 For functions:          template<class T> _IRR_DEPRECATED_ void test4(void) {}\r
104 **/\r
105 #if defined(IGNORE_DEPRECATED_WARNING)\r
106 #define _IRR_DEPRECATED_\r
107 #elif defined(_MSC_VER)\r
108 #define _IRR_DEPRECATED_ __declspec(deprecated)\r
109 #elif defined(__GNUC__)\r
110 #define _IRR_DEPRECATED_  __attribute__ ((deprecated))\r
111 #else\r
112 #define _IRR_DEPRECATED_\r
113 #endif\r
114 \r
115 //! deprecated macro for virtual function override\r
116 /** prefer to use the override keyword for new code */\r
117 #define _IRR_OVERRIDE_ override\r
118 \r
119 //! creates four CC codes used in Irrlicht for simple ids\r
120 /** some compilers can create those by directly writing the\r
121 code like 'code', but some generate warnings so we use this macro here */\r
122 #define MAKE_IRR_ID(c0, c1, c2, c3) \\r
123                 ((irr::u32)(irr::u8)(c0) | ((irr::u32)(irr::u8)(c1) << 8) | \\r
124                 ((irr::u32)(irr::u8)(c2) << 16) | ((irr::u32)(irr::u8)(c3) << 24 ))\r
125 \r
126 #endif // __IRR_TYPES_H_INCLUDED__\r