Browse Source

Attempt to fix VS2013 compatibility.

Alex Szpakowski 5 years ago
parent
commit
2eefa859e3
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/common/runtime.cpp

+ 9 - 2
src/common/runtime.cpp

@@ -35,6 +35,13 @@
 #include <cmath>
 #include <cmath>
 #include <sstream>
 #include <sstream>
 
 
+// VS2013 doesn't support alignof
+#if defined(_MSC_VER) && _MSC_VER <= 1800
+#define LOVE_ALIGNOF(x) __alignof(x)
+#else
+#define LOVE_ALIGNOF(x) alignof(x)
+#endif
+
 namespace love
 namespace love
 {
 {
 
 
@@ -98,7 +105,7 @@ static lua_Number luax_computeloveobjectkey(lua_State *L, love::Object *object)
 	// use more than 53 bits if their alignment is guaranteed to be more than 1.
 	// use more than 53 bits if their alignment is guaranteed to be more than 1.
 	// For example an alignment requirement of 8 means we can shift the
 	// For example an alignment requirement of 8 means we can shift the
 	// pointer's bits by 3.
 	// pointer's bits by 3.
-	const size_t minalign = alignof(std::max_align_t);
+	const size_t minalign = LOVE_ALIGNOF(std::max_align_t);
 	uintptr_t key = (uintptr_t) object;
 	uintptr_t key = (uintptr_t) object;
 
 
 	if ((key & (minalign - 1)) != 0)
 	if ((key & (minalign - 1)) != 0)
@@ -107,7 +114,7 @@ static lua_Number luax_computeloveobjectkey(lua_State *L, love::Object *object)
 				   "(pointer is %p but alignment should be %d)", object, minalign);
 				   "(pointer is %p but alignment should be %d)", object, minalign);
 	}
 	}
 
 
-	static const size_t shift = (size_t) log2(alignof(std::max_align_t));
+	static const size_t shift = (size_t) log2(LOVE_ALIGNOF(std::max_align_t));
 
 
 	key >>= shift;
 	key >>= shift;