[Mingw-users] stdio.h cannot be compiled with -std= compiler option

Zurück zum Archiv-Index
Eli Zaretskii eliz****@gnu*****
Fri Jan 11 18:03:20 JST 2019


With the latest MinGW runtime 5.2, this one-line program:

  #include <stdio.h>

doesn't compile if GCC is invoked with a -std= option:

  D:\usr\eli\data>gcc -std=c9x -c stdio.c
  In file included from stdio.c:1:0:
  d:\usr\include\stdio.h:790:34: error: unknown type name '__off64_t'
   typedef union { __int64 __value; __off64_t __offset; } fpos_t;
				    ^~~~~~~~~

AFAICT, this happens because stdio.h does this:

  #if !(defined __STRICT_ANSI__ || defined (__NO_MINGW_LFS)) \
   && defined (__MSVCRT__)
   /* ...while this is required to support our fseeko64() and ftello64()
    * implementations, (neither of which is in any way standardized)...
    */
  # define __need___off64_t
  #endif
  /* It is sufficient to test for just one define from each of the two
   * preceding groups...
   */
  #if defined __need_off_t || defined __need___off64_t
   /* ...to identify a requirement for selective inclusion of one or more
    * of these type definitions from "sys/types.h"; (note that we use the
    * #include "..." form here, to ensure that we get the correct header
    * file, relative to the location of this <stdio.h>).
    */
  # include "sys/types.h"
  #endif

followed by this:

  #ifdef __MSVCRT__
  typedef union { __int64 __value; __off64_t __offset; } fpos_t;
  #else
  typedef union { __int32 __value; __off32_t __offset; } fpos_t;
  #endif

IOW, __off64_t is defined (in sys/types.h) only if __STRICT_ANSI__ is
_not_ defined, but is then used regardless of __STRICT_ANSI__.

I didn't actually try, but a similar problem will probably happen if
someone uses -std=, but also wants to use the MinGW implementation of
fseek (which also uses the __off64_t data type).



More information about the MinGW-Users mailing list
Zurück zum Archiv-Index