> +  struct stat st;
> +  return
> +#if defined _WIN32 && ! defined __CYGWIN__
> +         _fstat (fd, &st) >= 0
> +#else
> +         fstat (fd, &st) >= 0
> +#endif

Oops, this doesn't work. On Windows, '_fstat' expects a 'struct _stat';
'struct stat' (on mingw) is a different type.

This patch fixes it.


2020-12-11  Bruno Haible  <[email protected]>

        execute-tests: Fix compilation error with MSVC.
        * tests/test-execute-child.c (is_device): With _fstat, use
        'struct _stat', not 'struct stat'.

diff --git a/tests/test-execute-child.c b/tests/test-execute-child.c
index 16ccff7..2310f77 100644
--- a/tests/test-execute-child.c
+++ b/tests/test-execute-child.c
@@ -29,14 +29,13 @@
 static int
 is_device (int fd)
 {
-  struct stat st;
-  return
 #if defined _WIN32 && ! defined __CYGWIN__
-         _fstat (fd, &st) >= 0
+  struct _stat st;
+  return _fstat (fd, &st) >= 0 && !((st.st_mode & S_IFMT) == S_IFREG);
 #else
-         fstat (fd, &st) >= 0
+  struct stat st;
+  return fstat (fd, &st) >= 0 && !S_ISREG (st.st_mode);
 #endif
-         && !S_ISREG (st.st_mode);
 }
 
 /* Now include the other header files.  */


Reply via email to