Discussion:
avoid accidental use of Windows APIs on Cygwin
(too old to reply)
Bruno Haible
2017-04-21 13:29:05 UTC
Permalink
Raw Message
On Cygwin, _WIN32 may or may not be defined. But we want to prefer the Cygwin
APIs in general (i.e. everywhere, except where explicitly coded otherwise).


2017-04-21 Bruno Haible <***@clisp.org>

Avoid accidental use of native Windows APIs on Cygwin.
* lib/getaddrinfo.c (WINDOWS_NATIVE): Don't define on Cygwin.
* lib/localcharset.c (WINDOWS_NATIVE): Likewise.
* lib/localename.c (WINDOWS_NATIVE): Likewise.

diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index 38f3dd1..7dd7c8e 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -54,7 +54,7 @@
# define PF_UNSPEC 0
#endif

-#if defined _WIN32 || defined __WIN32__
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
# define WINDOWS_NATIVE
#endif

diff --git a/lib/localcharset.c b/lib/localcharset.c
index ec86011..3c2b1ac 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -32,7 +32,7 @@
# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
#endif

-#if defined _WIN32 || defined __WIN32__
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
# define WINDOWS_NATIVE
# include <locale.h>
#endif
diff --git a/lib/localename.c b/lib/localename.c
index 89ce889..3ba9d08 100644
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -61,7 +61,7 @@ extern char * getlocalename_l(int, locale_t);
# endif
#endif

-#if defined _WIN32 || defined __WIN32__
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
# define WINDOWS_NATIVE
# if !defined IN_LIBINTL
# include "glthread/lock.h"

Loading...