Possible fix for non-MSVC windows compilers `_MSC_VER` is specific to MSVC, but there can be other compilers targeting windows. Hopefully they do define `_WIN32`, so let's use that. Refs: https://github.com/xkbcommon/libxkbcommon/issues/305 Signed-off-by: Ran Benita <ran@unusedvar.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
diff --git a/bench/bench.c b/bench/bench.c
index c28ac65..e6fb635 100644
--- a/bench/bench.c
+++ b/bench/bench.c
@@ -30,7 +30,7 @@
#include "bench.h"
#include "../src/utils.h"
-#ifndef _MSC_VER
+#ifndef _WIN32
#include <sys/time.h>
#else
#include <windows.h>
diff --git a/src/utils.h b/src/utils.h
index c263635..eec7f10 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -40,7 +40,7 @@
# define F_OK 0 /* Test for existence. */
#endif
-#ifdef _MSC_VER
+#ifdef _WIN32
# include <direct.h>
# include <io.h>
# ifndef S_ISDIR
diff --git a/test/common.c b/test/common.c
index 1d5a99d..cb911e8 100644
--- a/test/common.c
+++ b/test/common.c
@@ -37,7 +37,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef _MSC_VER
+#ifdef _WIN32
#include <io.h>
#include <windows.h>
#else
@@ -171,7 +171,7 @@ test_makedir(const char *parent, const char *path)
dirname = asprintf_safe("%s/%s", parent, path);
assert(dirname);
-#ifdef _MSC_VER
+#ifdef _WIN32
err = _mkdir(dirname);
#else
err = mkdir(dirname, 0777);
@@ -184,7 +184,7 @@ test_makedir(const char *parent, const char *path)
char *
test_maketempdir(const char *template)
{
-#ifdef _MSC_VER
+#ifdef _WIN32
const char *basetmp = getenv("TMP");
if (basetmp == NULL) {
basetmp = getenv("TEMP");
diff --git a/test/test.h b/test/test.h
index ba06deb..afeec78 100644
--- a/test/test.h
+++ b/test/test.h
@@ -88,7 +88,7 @@ test_compile_rules(struct xkb_context *context, const char *rules,
const char *options);
-#ifdef _MSC_VER
+#ifdef _WIN32
#define setenv(varname, value, overwrite) _putenv_s((varname), (value))
#define unsetenv(varname) _putenv_s(varname, "")
#endif
diff --git a/tools/tools-common.c b/tools/tools-common.c
index 254499d..63fce4e 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -39,7 +39,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef _MSC_VER
+#ifdef _WIN32
#include <io.h>
#include <windows.h>
#else
@@ -160,7 +160,7 @@ tools_print_state_changes(enum xkb_state_component changed)
printf("]\n");
}
-#ifdef _MSC_VER
+#ifdef _WIN32
void
tools_disable_stdin_echo(void)
{
diff --git a/tools/tools-common.h b/tools/tools-common.h
index 780720a..0c16505 100644
--- a/tools/tools-common.h
+++ b/tools/tools-common.h
@@ -54,7 +54,7 @@ tools_enable_stdin_echo(void);
int
tools_exec_command(const char *prefix, int argc, char **argv);
-#ifdef _MSC_VER
+#ifdef _WIN32
#define setenv(varname, value, overwrite) _putenv_s((varname), (value))
#define unsetenv(varname) _putenv_s(varname, "")
#endif