Commit 6165e34c authored by Richard Gobeille's avatar Richard Gobeille

engine: fixes for including compat.h in a C program built with MSVC

I needed to change the weird VS workaround in order for the EDUKE32_STATIC_ASSERT on line 850 to succeed.

Things seemed OK when I tested them, but I'd like more information on the suspected compiler bug in question and why this was necessary in the first place.
parent 917da2e3
......@@ -212,7 +212,7 @@
#if CXXSTD >= 2017
# define EDUKE32_STATIC_ASSERT(cond) static_assert(cond)
#elif CXXSTD >= 2011 || CSTD >= 2011 || EDUKE32_MSVC_CXX_PREREQ(1600)
#elif CXXSTD >= 2011 || CSTD >= 2011 || EDUKE32_MSVC_PREREQ(1600)
# define EDUKE32_STATIC_ASSERT(cond) static_assert(cond, "")
#else
/* C99 / C++03 static assertions based on source found in LuaJIT's src/lj_def.h. */
......@@ -248,7 +248,7 @@
#define STATIC_CAST(t, v) (STATIC_CAST_OP(t)(v))
#define REINTERPRET_CAST(t, v) (REINTERPRET_CAST_OP(t)(v))
#if defined __cplusplus && (__cplusplus >= 201103L || __has_feature(cxx_constexpr) || EDUKE32_MSVC_PREREQ(1900))
#if defined __cplusplus && (__cplusplus >= 201103L || __has_feature(cxx_constexpr) || EDUKE32_MSVC_CXX_PREREQ(1900))
# define HAVE_CONSTEXPR
# define CONSTEXPR constexpr
#else
......@@ -479,7 +479,7 @@ defined __x86_64__ || defined __amd64__ || defined _M_X64 || defined _M_IA64 ||
#ifdef _MSC_VER
# if defined _M_AMD64 || defined _M_ARM64 || defined _M_X64 || defined _WIN64
// should be int64_t, if not for a suspected VS compiler bug
typedef int32_t ssize_t;
typedef int64_t ssize_t;
# else
typedef int32_t ssize_t;
# endif
......@@ -1016,7 +1016,7 @@ static FORCE_INLINE CONSTEXPR uint64_t B_SWAP64_impl(uint64_t value)
}
/* The purpose of B_PASS* as functions, as opposed to macros, is to prevent them from being used as lvalues. */
#if CXXSTD >= 2011 || EDUKE32_MSVC_PREREQ(1900)
#if defined __cplusplus && (CXXSTD >= 2011 || EDUKE32_MSVC_CXX_PREREQ(1900))
template <typename T>
static FORCE_INLINE CONSTEXPR take_sign_t<int16_t, T> B_SWAP16(T x)
{
......@@ -1218,6 +1218,7 @@ static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int con
////////// Utility functions //////////
// breadth-first search helpers
#ifdef __cplusplus
template <typename T>
void bfirst_search_init(T *const list, uint8_t *const bitmap, T *const eltnumptr, int const maxelts, int const firstelt)
{
......@@ -1237,6 +1238,7 @@ void bfirst_search_try(T *const list, uint8_t *const bitmap, T *const eltnumptr,
list[(*eltnumptr)++] = elt;
}
}
#endif
#if RAND_MAX == 32767
static FORCE_INLINE uint16_t system_15bit_rand(void) { return (uint16_t)rand(); }
......@@ -1431,7 +1433,11 @@ static inline void maybe_grow_buffer(char ** const buffer, int32_t * const buffe
#define LIBDIVIDE_NOINLINE
#include "fix16.h"
#include "libdivide.h"
#ifdef __cplusplus
#include "clockticks.hpp"
#endif
#include "debugbreak.h"
#include "zpl.h"
......
......@@ -34,7 +34,7 @@ static CONSTEXPR const fix16_t FIX16_OVERFLOW = 0x80000000; /*!< the value used
static CONSTEXPR const fix16_t fix16_one = 0x00010000; /*!< fix16_t value of 1 */
static CONSTEXPR const fix16_t fix16_half = 0x00008000; /*!< fix16_t value of 0.5 */
static CONSTEXPR const float flt_f161r = 1.f / fix16_one; /*!< reciprocal of fix16_one as a float */
static CONSTEXPR const float flt_f161r = 1.f / 0x00010000; /*!< reciprocal of fix16_one as a float */
/* Conversion functions between fix16_t and float/integer.
* These are inlined to allow compiler to optimize away constant numbers
......
......@@ -5,6 +5,7 @@
#include <stdbool.h>
#ifdef _WIN32
# define NOMINMAX
# include <windows.h>
# ifdef VOIDWRAP_ISEXPORTING
# define VOIDWRAP_API __declspec(dllexport)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment