bug-gnulib
[Top][All Lists]
Advanced

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

MinGW compilation warning in fseeko


From: Eli Zaretskii
Subject: MinGW compilation warning in fseeko
Date: Sat, 12 May 2018 11:10:44 +0300

While building the latest pretest of wget2 with mingw.org's MinGW, I
saw this warning:

       CC       fseeko.lo
     fseeko.c: In function 'fseeko':
     fseeko.c:37:18: warning: implicit declaration of function '_fseeki64' 
[-Wimplicit-function-declaration]
      #  define fseeko _fseeki64
                       ^
     fseeko.c:163:10: note: in expansion of macro 'fseeko'
        return fseeko (fp, offset, whence);

This is because configure-time test for _fseeki64 succeeds, but the
prototype of _fseeki64 is not visible unless the condition

  _WIN32_WINNT >= 0x0600

holds, which it doesn't by default.  AFAICT, the test succeeds because
it arbitrarily provides (an incorrect) prototype for _fseeki64 and
because the libmsvcrt.a import library includes an entry for
_fseeki64, in order to be able to support Windows >= Vista, and that
allows the linking to succeed.

All this "mess" in MinGW is deliberate, because _fseeki64 is actually
available in the system C library only since Vista, and the MinGW
system headers are set up to produce executables that by default will
run on older versions of Windows.  A program must deliberately set
_WIN32_WINNT to a proper value to have the prototype of _fseeki64
visible.

So I think the test program for _fseeki64 should be changed to always
fail on MinGW if _WIN32_WINNT is less than 0x0600.

Alternatively, fseeko.c could be modified as follows:

diff --git a/lib/fseeko.c b/lib/fseeko.c
index e5c5172..172e934 100644
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -33,7 +33,7 @@ fseeko (FILE *fp, off_t offset, int whence)
 #endif
 #if _GL_WINDOWS_64_BIT_OFF_T
 # undef fseeko
-# if HAVE__FSEEKI64 /* msvc, mingw64 */
+# if HAVE__FSEEKI64 && _WIN32_WINNT >= 0x0600 /* msvc, mingw64 */
 #  define fseeko _fseeki64
 # else /* mingw */
 #  define fseeko fseeko64



reply via email to

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