aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-09-12 23:34:31 +0300
committerLasse Collin <lasse.collin@tukaani.org>2023-09-22 20:06:27 +0300
commit8c2d197c940d246849b2ec48109bb22e54036927 (patch)
treea6e3e24d2e77daf9ab9b2f8694081a38320fe8fd
parentCMake: Add support for replacement getopt_long (lib/getopt*). (diff)
downloadxz-8c2d197c940d246849b2ec48109bb22e54036927.tar.xz
MSVC: #define inline and restrict only when needed.
This also drops the check for _WIN32 as that shouldn't be needed.
-rw-r--r--src/common/sysdefs.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/sysdefs.h b/src/common/sysdefs.h
index 97be4ee3..07502dc9 100644
--- a/src/common/sysdefs.h
+++ b/src/common/sysdefs.h
@@ -151,13 +151,16 @@ typedef unsigned char _Bool;
#include <string.h>
-// As of MSVC 2013, inline and restrict are supported with
-// non-standard keywords.
-#if defined(_WIN32) && defined(_MSC_VER)
-# ifndef inline
+// Visual Studio 2013 update 2 supports only __inline, not inline.
+// MSVC v19.0 / VS 2015 and newer support both.
+//
+// MSVC v19.27 (VS 2019 version 16.7) added support for restrict.
+// Older ones support only __restrict.
+#ifdef _MSC_VER
+# if _MSC_VER < 1900 && !defined(inline)
# define inline __inline
# endif
-# ifndef restrict
+# if _MSC_VER < 1927 && !defined(restrict)
# define restrict __restrict
# endif
#endif