From 9933eae471c3c452c7aca1983434fc890ee60441 Mon Sep 17 00:00:00 2001 From: Jake Stine Date: Mon, 23 Nov 2020 11:57:48 -0800 Subject: [PATCH] msvc: fix syntax errors when compiling via msbuild 2019 compiler toolchain --- deps/libkirk/amctrl.c | 2 +- mednafen/clamp.h | 7 ++----- mednafen/mednafen-types.h | 7 +++++-- parallel-psx/util/util.hpp | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/deps/libkirk/amctrl.c b/deps/libkirk/amctrl.c index 0347dc39a..b1bb0b419 100644 --- a/deps/libkirk/amctrl.c +++ b/deps/libkirk/amctrl.c @@ -2,7 +2,7 @@ // Copyright (C) 2015 Hykem // Licensed under the terms of the GNU GPL, version 3 // http://www.gnu.org/licenses/gpl-3.0.txt - + #define _CRT_SECURE_NO_WARNINGS #include diff --git a/mednafen/clamp.h b/mednafen/clamp.h index 29d7c40aa..81dd60c0e 100644 --- a/mednafen/clamp.h +++ b/mednafen/clamp.h @@ -6,11 +6,8 @@ extern "C" { #endif #include -#ifndef _WIN32 -#include -#endif - -static INLINE void clamp(int32_t *val, ssize_t min, ssize_t max) +// ptrdiff_t (adopted by C99/C++) is generally a more portable version of ssize_t (POSIX only). +static INLINE void clamp(int32_t *val, ptrdiff_t min, ptrdiff_t max) { if(*val < min) *val = min; diff --git a/mednafen/mednafen-types.h b/mednafen/mednafen-types.h index 99eb5cedd..ec153cd0d 100644 --- a/mednafen/mednafen-types.h +++ b/mednafen/mednafen-types.h @@ -117,9 +117,9 @@ typedef uint64_t uint64; #define MDFN_MAKE_GCCV(maj,min,pl) (((maj)*100*100) + ((min) * 100) + (pl)) #define MDFN_GCC_VERSION MDFN_MAKE_GCCV(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#ifndef INLINE + #ifndef INLINE #define INLINE inline __attribute__((always_inline)) -#endif + #endif #define NO_INLINE __attribute__((noinline)) @@ -176,7 +176,10 @@ typedef uint64_t uint64; // Begin MSVC // + #if !defined(INLINE) #define INLINE __forceinline + #endif + #define NO_INLINE __declspec(noinline) #define NO_CLONE diff --git a/parallel-psx/util/util.hpp b/parallel-psx/util/util.hpp index b276b4411..84a710b7e 100644 --- a/parallel-psx/util/util.hpp +++ b/parallel-psx/util/util.hpp @@ -39,6 +39,7 @@ extern retro_log_printf_t libretro_log; #define LOGI(...) do { if (::Granite::libretro_log) ::Granite::libretro_log(RETRO_LOG_INFO, __VA_ARGS__); } while(0) #elif defined(_MSC_VER) #define WIN32_LEAN_AND_MEAN +#define NOMINMAX #include #define LOGE(...) do { \ fprintf(stderr, "[ERROR]: " __VA_ARGS__); \