summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/Globals.h b/src/Globals.h
index b8acfca64..c2542f0d8 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -38,6 +38,13 @@
// 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"
#elif defined(__GNUC__)
@@ -56,6 +63,12 @@
// 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"
#else
@@ -81,7 +94,7 @@
#endif
-
+#include <stddef.h>
// Integral types with predefined sizes:
@@ -96,8 +109,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 +207,7 @@ typedef unsigned char Byte;
#include <memory>
#include <set>
#include <queue>
-
+#include <limits>
@@ -220,9 +248,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
@@ -262,5 +291,3 @@ T Clamp(T a_Value, T a_Min, T a_Max)
#include "Entities/Effects.h"
-
-