summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/Globals.h b/src/Globals.h
index 28805a83f..3e62832b7 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -38,6 +38,15 @@
// No alignment needed in MSVC
#define ALIGN_8
#define ALIGN_16
+
+ #define FORMATSTRING(formatIndex, va_argsIndex)
+
+ // MSVC has its own custom version of zu format
+ #define SIZE_T_FMT "%Iu"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "Iu"
+ #define SIZE_T_FMT_HEX "%Ix"
+
+ #define NORETURN __declspec(noreturn)
#elif defined(__GNUC__)
@@ -56,6 +65,14 @@
// Some portability macros :)
#define stricmp strcasecmp
+
+ #define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
+
+ #define SIZE_T_FMT "%zu"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
+ #define SIZE_T_FMT_HEX "%zx"
+
+ #define NORETURN __attribute((__noreturn__))
#else
@@ -81,7 +98,14 @@
#endif
+#ifdef _DEBUG
+ #define NORETURNDEBUG NORETURN
+#else
+ #define NORETURNDEBUG
+#endif
+
+#include <stddef.h>
// Integral types with predefined sizes:
@@ -96,8 +120,23 @@ typedef unsigned short UInt16;
typedef unsigned char Byte;
+// If you get an error about specialization check the size of integral types
+template <typename T, size_t Size, bool x = sizeof(T) == Size>
+class SizeChecker;
+template <typename T, size_t Size>
+class SizeChecker<T, Size, true>
+{
+ T v;
+};
+
+template class SizeChecker<Int64, 8>;
+template class SizeChecker<Int32, 4>;
+template class SizeChecker<Int16, 2>;
+template class SizeChecker<UInt64, 8>;
+template class SizeChecker<UInt32, 4>;
+template class SizeChecker<UInt16, 2>;
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for any class that shouldn't allow copying itself
@@ -179,7 +218,7 @@ typedef unsigned char Byte;
#include <memory>
#include <set>
#include <queue>
-
+#include <limits>
@@ -220,9 +259,10 @@ typedef unsigned char Byte;
// Pretty much the same as ASSERT() but stays in Release builds
#define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) )
-
-
-
+// Same as assert but in all Self test builds
+#ifdef SELF_TEST
+#define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0))
+#endif
/// A generic interface used mainly in ForEach() functions
template <typename Type> class cItemCallback
@@ -246,6 +286,14 @@ T Clamp(T a_Value, T a_Min, T a_Max)
+#ifndef TOLUA_TEMPLATE_BIND
+#define TOLUA_TEMPLATE_BIND(x)
+#endif
+
+
+
+
+
// Common headers (part 2, with macros):
#include "ChunkDef.h"
#include "BiomeDef.h"
@@ -254,5 +302,3 @@ T Clamp(T a_Value, T a_Min, T a_Max)
#include "Entities/Effects.h"
-
-