use _WIN32 instead of windows.h to check for windows

Submitted by Adrian Johnson on Sept. 2, 2017, 10:17 a.m.

Details

Message ID 1234b36e-3d7f-f6b7-9aa1-9d0ba75af511@redneon.com
State New
Series "use _WIN32 instead of windows.h to check for windows"
Headers show

Commit Message

Adrian Johnson Sept. 2, 2017, 10:17 a.m.
configure.ac enables the win32 surface on cygwin where it is not
wanted[1] as cygwin is a POSIX environment.

[1] https://cygwin.com/faq.html#faq.programming.unix-gui

Patch hide | download patch | download mbox

From 901d0a1db0d2ea7330d08da2c8429458c4ee1e5d Mon Sep 17 00:00:00 2001
From: Adrian Johnson <ajohnson@redneon.com>
Date: Sat, 2 Sep 2017 19:09:49 +0930
Subject: [PATCH 1/2] build: use _WIN32 instead of windows.h to check for
 windows build

ifdef _WIN32 is the recommended way to check for a windows build [1]
and avoids identifying cygwin as windows.

based on the patch at [2]

[1] https://lists.gnu.org/archive/html/autoconf/2012-02/msg00008.html
[2] https://lists.gnu.org/archive/html/autoconf/2012-02/msg00009.html
---
 build/configure.ac.system | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/build/configure.ac.system b/build/configure.ac.system
index b9d71c8d7..915b42b46 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -110,9 +110,11 @@  dnl check for misc headers and functions
 AC_CHECK_HEADERS([libgen.h byteswap.h signal.h setjmp.h fenv.h sys/wait.h])
 AC_CHECK_FUNCS([ctime_r drand48 flockfile funlockfile getline link strndup])
 
-dnl check for win32 headers (this detects mingw as well)
-AC_CHECK_HEADERS([windows.h], have_windows=yes, have_windows=no)
-
+dnl Check if the runtime platform is a native Win32 host.
+AC_COMPILE_IFELSE([[
+#ifdef _WIN32
+ choke me
+#endif]], [have_windows=no], [have_windows=yes])
 
 dnl Possible headers for mkdir
 AC_CHECK_HEADERS([sys/stat.h io.h])
-- 
2.11.0


Comments

Bryce Harrington Sept. 5, 2017, 6:37 p.m.
On Sat, Sep 02, 2017 at 07:47:40PM +0930, Adrian Johnson wrote:
> configure.ac enables the win32 surface on cygwin where it is not
> wanted[1] as cygwin is a POSIX environment.
> 
> [1] https://cygwin.com/faq.html#faq.programming.unix-gui

> From 901d0a1db0d2ea7330d08da2c8429458c4ee1e5d Mon Sep 17 00:00:00 2001
> From: Adrian Johnson <ajohnson@redneon.com>
> Date: Sat, 2 Sep 2017 19:09:49 +0930
> Subject: [PATCH 1/2] build: use _WIN32 instead of windows.h to check for
>  windows build
> 
> ifdef _WIN32 is the recommended way to check for a windows build [1]
> and avoids identifying cygwin as windows.
> 
> based on the patch at [2]
> 
> [1] https://lists.gnu.org/archive/html/autoconf/2012-02/msg00008.html
> [2] https://lists.gnu.org/archive/html/autoconf/2012-02/msg00009.html
> ---
>  build/configure.ac.system | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

I notice the comment about mingw; is that worth doublechecking?  I don't
feel knowledgeable enough on WIN32 to review the patch, but conceptually
this seems sensible, and if it causes issues they'll be pretty obvious.
I'll defer to anyone knowledgeable on WIN32, but offhand I have no
qualms seeing this land on trunk, and seeing how things shake out:

Acked-by: Bryce Harrington <bryce@osg.samsung.com>
 
> diff --git a/build/configure.ac.system b/build/configure.ac.system
> index b9d71c8d7..915b42b46 100644
> --- a/build/configure.ac.system
> +++ b/build/configure.ac.system
> @@ -110,9 +110,11 @@ dnl check for misc headers and functions
>  AC_CHECK_HEADERS([libgen.h byteswap.h signal.h setjmp.h fenv.h sys/wait.h])
>  AC_CHECK_FUNCS([ctime_r drand48 flockfile funlockfile getline link strndup])
>  
> -dnl check for win32 headers (this detects mingw as well)
> -AC_CHECK_HEADERS([windows.h], have_windows=yes, have_windows=no)
> -
> +dnl Check if the runtime platform is a native Win32 host.
> +AC_COMPILE_IFELSE([[
> +#ifdef _WIN32
> + choke me
> +#endif]], [have_windows=no], [have_windows=yes])
>  
>  dnl Possible headers for mkdir
>  AC_CHECK_HEADERS([sys/stat.h io.h])
> -- 
> 2.11.0
> 

> -- 
> cairo mailing list
> cairo@cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo