bug-gnulib
[Top][All Lists]
Advanced

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

Compilation errors using Gnulib's time.h on MinGW


From: Eli Zaretskii
Subject: Compilation errors using Gnulib's time.h on MinGW
Date: Sat, 12 May 2018 10:52:48 +0300

The problem described below was found when building the latest pretest
of wget2 with mingw.org's MinGW system headers and libraries.

Compilation of utimens.c fails thusly:

     In file included from ./sys/stat.h:47:0,
                      from ./fcntl.h:58,
                      from utimens.c:28:
     d:\usr\include\sys\stat.h:173:14: error: unknown type name '_dev_t'
      struct _stat __struct_stat_defined( _off_t, time_t );
                   ^
     d:\usr\include\sys\stat.h:173:14: error: unknown type name '_ino_t'
      struct _stat __struct_stat_defined( _off_t, time_t );
                   ^
     d:\usr\include\sys\stat.h:173:14: error: unknown type name '_mode_t'
      struct _stat __struct_stat_defined( _off_t, time_t );
                   ^
     d:\usr\include\sys\stat.h:173:14: error: unknown type name '_dev_t'
      struct _stat __struct_stat_defined( _off_t, time_t );
                   ^
     d:\usr\include\sys\stat.h:173:14: error: unknown type name '_off_t'
      struct _stat __struct_stat_defined( _off_t, time_t );
                   ^
     d:\usr\include\sys\stat.h:180:13: error: unknown type name '_dev_t'
      struct stat __struct_stat_defined( _off_t, time_t );
                  ^
     d:\usr\include\sys\stat.h:180:13: error: unknown type name '_ino_t'
      struct stat __struct_stat_defined( _off_t, time_t );
                  ^
     d:\usr\include\sys\stat.h:180:13: error: unknown type name '_mode_t'
      struct stat __struct_stat_defined( _off_t, time_t );
                  ^
     d:\usr\include\sys\stat.h:180:13: error: unknown type name '_dev_t'
      struct stat __struct_stat_defined( _off_t, time_t );
                  ^
     d:\usr\include\sys\stat.h:180:13: error: unknown type name '_off_t'
      struct stat __struct_stat_defined( _off_t, time_t );
                  ^
     d:\usr\include\sys\stat.h:188:17: error: unknown type name '_dev_t'
      struct _stati64 __struct_stat_defined( __off64_t, time_t );
                      ^
     d:\usr\include\sys\stat.h:188:17: error: unknown type name '_ino_t'
      struct _stati64 __struct_stat_defined( __off64_t, time_t );
                      ^
     d:\usr\include\sys\stat.h:188:17: error: unknown type name '_mode_t'
      struct _stati64 __struct_stat_defined( __off64_t, time_t );
                      ^
     d:\usr\include\sys\stat.h:188:17: error: unknown type name '_dev_t'
      struct _stati64 __struct_stat_defined( __off64_t, time_t );
                      ^
     d:\usr\include\sys\stat.h:188:17: error: unknown type name '__off64_t'
      struct _stati64 __struct_stat_defined( __off64_t, time_t );
                      ^
     d:\usr\include\sys\stat.h:195:17: error: unknown type name '_dev_t'
      struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                      ^
     d:\usr\include\sys\stat.h:195:17: error: unknown type name '_ino_t'
      struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                      ^
     d:\usr\include\sys\stat.h:195:17: error: unknown type name '_mode_t'
      struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                      ^
     d:\usr\include\sys\stat.h:195:17: error: unknown type name '_dev_t'
      struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                      ^
     d:\usr\include\sys\stat.h:195:17: error: unknown type name '__off64_t'
      struct __stat64 __struct_stat_defined( __off64_t, __time64_t );
                      ^
     In file included from ./sys/stat.h:513:0,
                      from ./fcntl.h:58,
                      from utimens.c:28:
     d:\usr\include\io.h:503:14: error: unknown type name '__off64_t'
      __CRT_INLINE __off64_t lseek64 (int, __off64_t, int);
                   ^~~~~~~~~
     d:\usr\include\io.h:503:38: error: unknown type name '__off64_t'
      __CRT_INLINE __off64_t lseek64 (int, __off64_t, int);
                                           ^~~~~~~~~
     d:\usr\include\io.h:505:1: error: unknown type name '__off64_t'
      __off64_t lseek64 (int fd, __off64_t offset, int whence)
      ^~~~~~~~~
     d:\usr\include\io.h:505:28: error: unknown type name '__off64_t'
      __off64_t lseek64 (int fd, __off64_t offset, int whence)
                                 ^~~~~~~~~
     In file included from utimens.h:20:0,
                      from utimens.c:25:
     ./sys/stat.h:1023:1: error: unknown type name 'mode_t'
      _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
      ^
     In file included from d:\usr\include\unistd.h:57:0,
                      from ./unistd.h:40,
                      from ./fcntl.h:67,
                      from utimens.c:28:
     d:\usr\include\process.h:99:53: error: unknown type name '_pid_t'
      _CRTIMP __cdecl __MINGW_NOTHROW  int _cwait (int *, _pid_t, int);
                                                          ^~~~~~
     d:\usr\include\process.h:101:34: error: unknown type name '_pid_t'
      _CRTIMP __cdecl __MINGW_NOTHROW  _pid_t _getpid (void);
                                       ^~~~~~
     d:\usr\include\process.h:177:52: error: unknown type name 'pid_t'
      _CRTIMP __cdecl __MINGW_NOTHROW  int cwait (int *, pid_t, int);
                                                         ^~~~~
     d:\usr\include\process.h:178:34: error: unknown type name 'pid_t'
      _CRTIMP __cdecl __MINGW_NOTHROW  pid_t getpid (void);
                                       ^~~~~
     In file included from d:\usr\include\time.h:45:0,
                      from ./time.h:41,
                      from utimens.h:20,
                      from utimens.c:25:
     d:\usr\include\sys/types.h:75:19: error: two or more data types in 
declaration specifiers
        typedef _off_t  off_t;
                        ^
     d:\usr\include\sys/types.h:75:19: error: two or more data types in 
declaration specifiers
        typedef _off_t  off_t;
                        ^
     d:\usr\include\sys/types.h:75:19: error: two or more data types in 
declaration specifiers
        typedef _off_t  off_t;
                        ^
     Makefile:1931: recipe for target `utimens.lo' failed
     make[3]: *** [utimens.lo] Error 1

Similar errors happen in nanosleep.c and in libwget/thread.c.  All of
the types that GCC complains about are defined in MinGW's sys/types.h.

The reason for all these errors is the fact that Gnulib's
sys_types.in.h does this:

  #ifndef address@hidden@_SYS_TYPES_H

  /* The include_next requires a split double-inclusion guard.  */
  # define _GL_INCLUDING_SYS_TYPES_H
  address@hidden@ @NEXT_SYS_TYPES_H@
  # undef _GL_INCLUDING_SYS_TYPES_H

  #ifndef address@hidden@_SYS_TYPES_H
  #define address@hidden@_SYS_TYPES_H

This assumes that the system header sys/types.h can be included just
once, anywhere in the program, and that is sufficient.  (MinGW's
time.h includes sys/types.h, which causes it to include Gnulib's
sys/types.h.)  Is that a portable assumption?

What happens with MinGW headers is that when MinGW's sys/types.h is
included from time.h, only a small portion of sys/types.h is
processed, the one that is relevant to time.h types, and that portion
doesn't include the types mentioned in the above error messages.  The
next time sys/types.h is included by the program, the Gnulib header
decides it doesn't need to delegate to the system header, because
address@hidden@_SYS_TYPES_H is already defined.  So the relevant
portions of MinGW's sys/types.h are skipped, and we get the error
messages.

My semi-kludgey solution was to include sys/types.h explicitly before
including time.h.  I hope there's a more elegant solution, preferably
internal to Gnulib.

Thanks.

P.S. Please CC me on any responses, as I'm not subscribed to the list.



reply via email to

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