Discussion:
Compilation errors using Gnulib's time.h on MinGW
Eli Zaretskii
2018-05-13 15:31:31 UTC
Permalink
Date: Sat, 12 May 2018 10:44:54 +0200
Please can you attach
- a copy of the mingw <time.h>,
- a copy of the mingw <sys/types.h>,
- the result of preprocessing utimens.c with "-E"?
Attached below.
Eli Zaretskii
2018-05-12 09:26:46 UTC
Permalink
Date: Sat, 12 May 2018 10:44:54 +0200
Hi Eli,
The problem described below was found when building the latest pretest
of wget2 with mingw.org's MinGW system headers and libraries.
Oh, there are still people who use the (old) mingw.org system?
It is "old" only in the sense that it was the first one on the block.
It is still being maintained, albeit slower than mingw64.
<time.h> https://sourceforge.net/p/mingw/mingw-org-wsl/ci/21762bb4a1bd0c88c38eead03f59e8d994349e83/tree/include/time.h
which also does not fit your description: it doesn't include <sys/types.h>.
This is the wrong version. The latest development is here, AFAIU:

https://sourceforge.net/p/mingw/mingw-org-wsl/ci/5.1-trunk/tree/mingwrt/include/time.h

and it does include sys/types.h.

The build whose problems I described used MinGW 5.0.1, I believe its
sources are on the 5.0-active branch.
Please can you attach
- a copy of the mingw <time.h>,
- a copy of the mingw <sys/types.h>,
- the result of preprocessing utimens.c with "-E"?
Will do, thanks.
Bruno Haible
2018-05-13 20:20:06 UTC
Permalink
Post by Eli Zaretskii
Attached below.
Thanks. The following patch should fix this scenario (or at least, make it
easier to solve).


2018-05-13 Bruno Haible <***@clisp.org>

Support selective inclusion mechanism of recent mingw.org header files.
Reported by Eli Zaretskii <***@gnu.org>.
* lib/sys_types.in.h: On mingw, when __need_off_t, __need___off64_t,
__need_ssize_t, or __need_time_t is defined, just include the system's
<sys/types.h>.
* lib/locale.in.h: On mingw, when __need_locale_t is defined, just
include the system's <locale.h>.

diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 0f75f4e..440eeb3 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -20,6 +20,17 @@
#endif
@PRAGMA_COLUMNS@

+#if defined _WIN32 && !defined __CYGWIN__ \
+ && (defined __need_off_t || defined __need___off64_t \
+ || defined __need_ssize_t || defined __need_time_t)
+
+/* Special invocation convention inside mingw header files. */
+
+#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
+
+#else
+/* Normal invocation convention. */
+
#ifndef ***@GUARD_PREFIX@_SYS_TYPES_H

/* The include_next requires a split double-inclusion guard. */
@@ -92,3 +103,4 @@ typedef unsigned long long int rpl_ino_t;

#endif /* ***@GUARD_PREFIX@_SYS_TYPES_H */
#endif /* ***@GUARD_PREFIX@_SYS_TYPES_H */
+#endif /* __need_XXX */
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 1b27f1f..804261d 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -19,10 +19,13 @@
#endif
@PRAGMA_COLUMNS@

-#ifdef _GL_ALREADY_INCLUDING_LOCALE_H
+#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
+ || defined _GL_ALREADY_INCLUDING_LOCALE_H

-/* Special invocation conventions to handle Solaris header files
- (through Solaris 10) when combined with gettext's libintl.h. */
+/* Special invocation convention:
+ - Inside mingw header files,
+ - To handle Solaris header files (through Solaris 10) when combined
+ with gettext's libintl.h. */

#@INCLUDE_NEXT@ @NEXT_LOCALE_H@

@@ -212,5 +215,5 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
#endif

#endif /* ***@GUARD_PREFIX@_LOCALE_H */
-#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
#endif /* ***@GUARD_PREFIX@_LOCALE_H */
+#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
Loading...