OSDN Git Service

Don't implicitly define _POSIX_C_SOURCE too early.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 11 Dec 2014 09:58:09 +0000 (09:58 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 11 Dec 2014 09:58:09 +0000 (09:58 +0000)
mingwrt/ChangeLog
mingwrt/include/_mingw.h

index fdd024e..cbc429d 100644 (file)
@@ -1,3 +1,11 @@
+2014-12-11  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Don't implicitly define _POSIX_C_SOURCE too early.
+
+       * include/_mingw.h (_POSIX_C_SOURCE): Delay implict definition.
+       (__USE_MINGW_ANSI_STDIO): This must be initialized first, to ensure
+       that it is not accidentally activated by implied _POSIX_C_SOURCE.
+
 2014-12-10  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Correct complex arcsin computation per issue [#2245].
index 4c101eb..8d50363 100644 (file)
 #define __MINGW_LC_ENVVARS__           0x0000000000000040ULL
 
 
-#ifndef _POSIX_C_SOURCE
- /*
-  * Users may define this, either directly or indirectly, to explicitly
-  * enable a particular level of visibility for the subset of those POSIX
-  * features which are supported by MinGW; (notice that this offers no
-  * guarantee that any particular POSIX feature will be supported).
-  */
-# if defined _XOPEN_SOURCE
-  /*
-   * Specifying this is the preferred method for setting _POSIX_C_SOURCE;
-   * (POSIX defines an explicit relationship to _XOPEN_SOURCE).  Note that
-   * any such explicit setting will augment the set of features which are
-   * available to any compilation unit, even if it seeks to be strictly
-   * ANSI-C compliant.
-   */
-#  if _XOPEN_SOURCE < 500
-#   define _POSIX_C_SOURCE  1L         /* POSIX.1-1990 / SUSv1 */
-
-#  elif _XOPEN_SOURCE < 600
-#   define _POSIX_C_SOURCE  199506L    /* POSIX.1-1996 / SUSv2 */
-
-#  elif _XOPEN_SOURCE < 700
-#   define _POSIX_C_SOURCE  200112L    /* POSIX.1-2001 / SUSv3 */
-
-#  else
-#   define _POSIX_C_SOURCE  200809L    /* POSIX.1-2008 / SUSv4 */
-#  endif
-
-# elif defined _GNU_SOURCE || defined _BSD_SOURCE || ! defined __STRICT_ANSI__
-  /*
-   * No explicit level of support has been specified; implicitly grant
-   * the most comprehensive level to any compilation unit which requests
-   * either GNU or BSD feature support, or does not seek to be strictly
-   * ANSI-C compliant.
-   */
-#  define _POSIX_C_SOURCE  200809L
-
-# elif defined _POSIX_SOURCE
-  /*
-   * Now formally deprecated by POSIX, some old code may specify this;
-   * it will enable a minimal level of POSIX support, in addition to the
-   * limited feature set enabled for strict ANSI-C conformity.
-   */
-#  define _POSIX_C_SOURCE  1L
-# endif
-#endif
-
-
 /* Try to avoid problems with outdated checks for GCC __attribute__ support.
  */
 #undef __attribute__
@@ -396,7 +348,9 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
  */
 #ifndef __USE_MINGW_ANSI_STDIO
 /*
- * If user didn't specify it explicitly...
+ * We must check this BEFORE we specifiy any implicit _POSIX_C_SOURCE,
+ * otherwise we would always implicitly choose __USE_MINGW_ANSI_STDIO;
+ * if user didn't specify it explicitly...
  */
 # if   defined __STRICT_ANSI__  ||  defined _ISOC99_SOURCE \
    ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE \
@@ -409,13 +363,60 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
     */
 #  define __USE_MINGW_ANSI_STDIO    1
 # else
-   /*
-    * otherwise use whatever __MINGW_FEATURES__ specifies...
+   /* otherwise use whatever __MINGW_FEATURES__ specifies...
     */
 #  define __USE_MINGW_ANSI_STDIO    (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
 # endif
 #endif
 
+#ifndef _POSIX_C_SOURCE
+ /*
+  * Users may define this, either directly or indirectly, to explicitly
+  * enable a particular level of visibility for the subset of those POSIX
+  * features which are supported by MinGW; (notice that this offers no
+  * guarantee that any particular POSIX feature will be supported).
+  */
+# if defined _XOPEN_SOURCE
+  /*
+   * Specifying this is the preferred method for setting _POSIX_C_SOURCE;
+   * (POSIX defines an explicit relationship to _XOPEN_SOURCE).  Note that
+   * any such explicit setting will augment the set of features which are
+   * available to any compilation unit, even if it seeks to be strictly
+   * ANSI-C compliant.
+   */
+#  if _XOPEN_SOURCE < 500
+#   define _POSIX_C_SOURCE  1L         /* POSIX.1-1990 / SUSv1 */
+
+#  elif _XOPEN_SOURCE < 600
+#   define _POSIX_C_SOURCE  199506L    /* POSIX.1-1996 / SUSv2 */
+
+#  elif _XOPEN_SOURCE < 700
+#   define _POSIX_C_SOURCE  200112L    /* POSIX.1-2001 / SUSv3 */
+
+#  else
+#   define _POSIX_C_SOURCE  200809L    /* POSIX.1-2008 / SUSv4 */
+#  endif
+
+# elif defined _GNU_SOURCE || defined _BSD_SOURCE || ! defined __STRICT_ANSI__
+  /*
+   * No explicit level of support has been specified; implicitly grant
+   * the most comprehensive level to any compilation unit which requests
+   * either GNU or BSD feature support, or does not seek to be strictly
+   * ANSI-C compliant.
+   */
+#  define _POSIX_C_SOURCE  200809L
+
+# elif defined _POSIX_SOURCE
+  /*
+   * Now formally deprecated by POSIX, some old code may specify this;
+   * it will enable a minimal level of POSIX support, in addition to the
+   * limited feature set enabled for strict ANSI-C conformity.
+   */
+#  define _POSIX_C_SOURCE  1L
+# endif
+#endif
+
+
 /* Only Microsoft could attempt to justify this insanity: when building
  * a UTF-16LE application -- apparently their understanding of Unicode is
  * limited to this -- the C/C++ runtime requires that the user must define