[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MinGW compilation warning in fseeko

From: Bruno Haible
Subject: Re: MinGW compilation warning in fseeko
Date: Sat, 12 May 2018 20:40:46 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; )

Eli Zaretskii wrote:
> > Do you know how to distinguish the two, just by preprocessor defines,
> > without any autoconf test?
> AFAIK, it's tricky, because MinGW64 also defines __MINGW32__, and
> doesn't have any macro specific to it that is defined by the compiler
> itself.  In Emacs we use this ugly hack to resolve the problem:
>   /* MinGW-w64 gcc does not automatically define a macro for
>      differentiating it fom MinGW gcc. We need to test the presence of
>      __MINGW64_VERSION_MAJOR in _mingw.h: */
>   #ifdef __MINGW32__
>   # include <_mingw.h>
>   # ifdef __MINGW64_VERSION_MAJOR
>   #  define MINGW_W64
>   # endif
>   #endif
> and then test MINGW_W64 elsewhere.

Thanks for showing this. But this seems to introduce more, not less fragility.

I don't want to revert the #if, i.e. prefer fseeko64 to _fseeki64, because
the idea of mingw is to use the maximum of functions from the CRT DLLs.

So I ended up adding the test for the declaration of _fseeki64:

2018-05-12  Bruno Haible  <address@hidden>

        fseeko: On mingw, don't use the hidden function _fseeki64.
        Reported by Eli Zaretskii <address@hidden>.
        * m4/fseeko.m4 (gl_PREREQ_FSEEKO): Test whether _fseeki64 is declared.
        * lib/fseeko.c (fseeko): Use _fseeki64 only if it is declared.

diff --git a/m4/fseeko.m4 b/m4/fseeko.m4
index 8967cf1..86c246e 100644
--- a/m4/fseeko.m4
+++ b/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 18
+# fseeko.m4 serial 19
 dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -68,7 +68,10 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
 # Prerequisites of lib/fseeko.c.
-  dnl Native Windows has the function _fseeki64. mingw hides it, but mingw64
-  dnl makes it usable again.
+  dnl Native Windows has the function _fseeki64. mingw hides it in some
+  dnl circumstances, but mingw64 makes it usable again.
+  if test $ac_cv_func__fseeki64 = yes; then
+    AC_CHECK_DECLS([_fseeki64])
+  fi
diff --git a/lib/fseeko.c b/lib/fseeko.c
index e5c5172..d47481d 100644
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -33,9 +33,9 @@ fseeko (FILE *fp, off_t offset, int whence)
 # undef fseeko
-# if HAVE__FSEEKI64 /* msvc, mingw64 */
+# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, 
mingw64 */
 #  define fseeko _fseeki64
-# else /* mingw */
+# else /* mingw before msvcrt8.0 */
 #  define fseeko fseeko64
 # endif

reply via email to

[Prev in Thread] Current Thread [Next in Thread]