2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
#ifndef IRR_TYPES_H_INCLUDED
|
|
|
|
#define IRR_TYPES_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
|
|
|
|
#if defined(__GNUC__)
|
2022-01-04 19:44:35 +01:00
|
|
|
// For __WORDSIZE (which we maybe don't even need anymore with LP64 checks now)
|
|
|
|
#include <limits.h>
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
|
|
|
|
//! 8 bit unsigned variable.
|
|
|
|
/** This is a typedef for unsigned char, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef unsigned __int8 u8;
|
|
|
|
#else
|
|
|
|
typedef unsigned char u8;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//! 8 bit signed variable.
|
|
|
|
/** This is a typedef for signed char, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef __int8 s8;
|
|
|
|
#else
|
|
|
|
typedef signed char s8;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//! 8 bit character variable.
|
|
|
|
/** This is a typedef for char, it ensures portability of the engine. */
|
|
|
|
typedef char c8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! 16 bit unsigned variable.
|
|
|
|
/** This is a typedef for unsigned short, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef unsigned __int16 u16;
|
|
|
|
#else
|
|
|
|
typedef unsigned short u16;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//! 16 bit signed variable.
|
|
|
|
/** This is a typedef for signed short, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef __int16 s16;
|
|
|
|
#else
|
|
|
|
typedef signed short s16;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! 32 bit unsigned variable.
|
|
|
|
/** This is a typedef for unsigned int, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef unsigned __int32 u32;
|
|
|
|
#else
|
|
|
|
typedef unsigned int u32;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//! 32 bit signed variable.
|
|
|
|
/** This is a typedef for signed int, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef __int32 s32;
|
|
|
|
#else
|
|
|
|
typedef signed int s32;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __IRR_HAS_S64
|
|
|
|
//! 64 bit unsigned variable.
|
|
|
|
/** This is a typedef for 64bit uint, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef unsigned __int64 u64;
|
|
|
|
#elif defined(__GNUC__)
|
2022-01-04 19:44:35 +01:00
|
|
|
#if (defined(__LP64__) && __LP64__ == 1) || (defined(_LP64) && _LP64 == 1) || (defined(__WORDSIZE) && __WORDSIZE == 64)
|
2019-12-12 17:32:41 +01:00
|
|
|
typedef unsigned long int u64;
|
|
|
|
#else
|
|
|
|
__extension__ typedef unsigned long long u64;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
typedef unsigned long long u64;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//! 64 bit signed variable.
|
|
|
|
/** This is a typedef for 64bit int, it ensures portability of the engine. */
|
|
|
|
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
|
|
|
|
typedef __int64 s64;
|
|
|
|
#elif defined(__GNUC__)
|
2022-01-04 19:44:35 +01:00
|
|
|
#if (defined(__LP64__) && __LP64__ == 1) || (defined(_LP64) && _LP64 == 1) || (defined(__WORDSIZE) && __WORDSIZE == 64)
|
2019-12-12 17:32:41 +01:00
|
|
|
typedef long int s64;
|
|
|
|
#else
|
|
|
|
__extension__ typedef long long s64;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
typedef long long s64;
|
|
|
|
#endif
|
|
|
|
#endif // __IRR_HAS_S64
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! 32 bit floating point variable.
|
|
|
|
/** This is a typedef for float, it ensures portability of the engine. */
|
|
|
|
typedef float f32;
|
|
|
|
|
|
|
|
//! 64 bit floating point variable.
|
|
|
|
/** This is a typedef for double, it ensures portability of the engine. */
|
|
|
|
typedef double f64;
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
|
|
|
|
#include <wchar.h>
|
|
|
|
#ifdef _IRR_WINDOWS_API_
|
|
|
|
//! Defines for s{w,n}printf_irr because s{w,n}printf methods do not match the ISO C
|
|
|
|
//! standard on Windows platforms.
|
|
|
|
//! We want int snprintf_irr(char *str, size_t size, const char *format, ...);
|
|
|
|
//! and int swprintf_irr(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
|
|
|
|
#if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
|
|
|
|
#define swprintf_irr swprintf_s
|
|
|
|
#define snprintf_irr sprintf_s
|
|
|
|
#elif !defined(__CYGWIN__)
|
|
|
|
#define swprintf_irr _snwprintf
|
|
|
|
#define snprintf_irr _snprintf
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// define the wchar_t type if not already built in.
|
2021-08-27 14:55:10 +02:00
|
|
|
// It's usually set when VS compiler sets /Zc:wchar_t
|
2019-12-12 17:32:41 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#ifndef _WCHAR_T_DEFINED
|
|
|
|
//! A 16 bit wide character type.
|
|
|
|
/**
|
|
|
|
Defines the wchar_t-type.
|
|
|
|
In VS6, its not possible to tell
|
|
|
|
the standard compiler to treat wchar_t as a built-in type, and
|
|
|
|
sometimes we just don't want to include the huge stdlib.h or wchar.h,
|
|
|
|
so we'll use this.
|
|
|
|
*/
|
|
|
|
typedef unsigned short wchar_t;
|
|
|
|
#define _WCHAR_T_DEFINED
|
|
|
|
#endif // wchar is not defined
|
|
|
|
#endif // microsoft compiler
|
|
|
|
#else
|
|
|
|
#define swprintf_irr swprintf
|
|
|
|
#define snprintf_irr snprintf
|
|
|
|
#endif // _IRR_WINDOWS_API_
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
//! Type name for character type used by the filesystem.
|
|
|
|
/** Should the wide character version of the filesystem be used it is a
|
|
|
|
16 bit character variable. Used for Unicode filesystem and Unicode strings.
|
|
|
|
Else it is a 8 bit character variable. Used for ansi filesystem and non-unicode
|
2019-12-12 17:32:41 +01:00
|
|
|
strings
|
|
|
|
*/
|
|
|
|
#if defined(_IRR_WCHAR_FILESYSTEM)
|
|
|
|
typedef wchar_t fschar_t;
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_TEXT(X) L##X
|
2019-12-12 17:32:41 +01:00
|
|
|
#else
|
|
|
|
typedef char fschar_t;
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_TEXT(X) X
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
//! define a break macro for debugging.
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && !defined (_WIN32_WCE)
|
|
|
|
#if defined(WIN64) || defined(_WIN64) // using portable common solution for x64 configuration
|
|
|
|
#include <crtdbg.h>
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();}
|
2019-12-12 17:32:41 +01:00
|
|
|
#else
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#include "assert.h"
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) );
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
#else
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//! Defines a deprecated macro which generates a warning at compile time
|
|
|
|
/** The usage is simple
|
2021-08-27 14:55:10 +02:00
|
|
|
For typedef: typedef IRR_DEPRECATED int test1;
|
|
|
|
For classes/structs: class IRR_DEPRECATED test2 { ... };
|
|
|
|
For methods: class test3 { IRR_DEPRECATED virtual void foo() {} };
|
|
|
|
For functions: template<class T> IRR_DEPRECATED void test4(void) {}
|
2019-12-12 17:32:41 +01:00
|
|
|
**/
|
|
|
|
#if defined(IGNORE_DEPRECATED_WARNING)
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEPRECATED
|
2019-12-12 17:32:41 +01:00
|
|
|
#elif _MSC_VER >= 1310 //vs 2003 or higher
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEPRECATED __declspec(deprecated)
|
2019-12-12 17:32:41 +01:00
|
|
|
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // all versions above 3.0 should support this feature
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEPRECATED __attribute__ ((deprecated))
|
2019-12-12 17:32:41 +01:00
|
|
|
#else
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_DEPRECATED
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//! Defines an override macro, to protect virtual functions from typos and other mismatches
|
|
|
|
/** Usage in a derived class:
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void somefunc() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
*/
|
|
|
|
#if ( ((__GNUC__ > 4 ) || ((__GNUC__ == 4 ) && (__GNUC_MINOR__ >= 7))) && (defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L) )
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_OVERRIDE override
|
2019-12-12 17:32:41 +01:00
|
|
|
#elif (_MSC_VER >= 1600 ) /* supported since MSVC 2010 */
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_OVERRIDE override
|
2019-12-12 17:32:41 +01:00
|
|
|
#elif (__clang_major__ >= 3 && __has_feature(cxx_override_control))
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_OVERRIDE override
|
2019-12-12 17:32:41 +01:00
|
|
|
#else
|
2021-08-27 14:55:10 +02:00
|
|
|
#define IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// memory debugging
|
|
|
|
#if defined(_DEBUG) && defined(IRRLICHT_EXPORTS) && defined(_MSC_VER) && \
|
2021-08-27 14:55:10 +02:00
|
|
|
(_MSC_VER > 1299) && !defined(IRR_DONT_DO_MEMORY_DEBUGGING_HERE) && !defined(_WIN32_WCE)
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#define CRTDBG_MAP_ALLOC
|
|
|
|
#define _CRTDBG_MAP_ALLOC
|
|
|
|
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <crtdbg.h>
|
|
|
|
#define new DEBUG_CLIENTBLOCK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//! ignore VC8 warning deprecated
|
|
|
|
/** The Microsoft compiler */
|
|
|
|
#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER >= 1400)
|
|
|
|
//#pragma warning( disable: 4996)
|
|
|
|
//#define _CRT_SECURE_NO_DEPRECATE 1
|
|
|
|
//#define _CRT_NONSTDC_NO_DEPRECATE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//! creates four CC codes used in Irrlicht for simple ids
|
|
|
|
/** some compilers can create those by directly writing the
|
|
|
|
code like 'code', but some generate warnings so we use this macro here */
|
|
|
|
#define MAKE_IRR_ID(c0, c1, c2, c3) \
|
|
|
|
((irr::u32)(irr::u8)(c0) | ((irr::u32)(irr::u8)(c1) << 8) | \
|
|
|
|
((irr::u32)(irr::u8)(c2) << 16) | ((irr::u32)(irr::u8)(c3) << 24 ))
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
#endif // IRR_TYPES_H_INCLUDED
|