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