OSDN Git Service

Update ANSI stdio feature test to accommodate ISO-C11.
authorKeith Marshall <keith@users.osdn.me>
Sat, 22 Dec 2018 16:52:51 +0000 (16:52 +0000)
committerKeith Marshall <keith@users.osdn.me>
Sat, 22 Dec 2018 16:52:51 +0000 (16:52 +0000)
mingwrt/ChangeLog
mingwrt/include/_mingw.h.in

index 3e9eca9..a5f663e 100644 (file)
@@ -1,3 +1,12 @@
+2018-12-22  Keith Marshall  <keith@users.osdn.me>
+
+       Update ANSI stdio feature test to accommodate ISO-C11.
+
+       * include/_mingw.h.in (__USE_MINGW_ANSI_STDIO): Add a deprecation
+       warning, for ill-advised direct definition in user code; include...
+       (_ISOC11_SOURCE): ...this new user defined feature test macro as a
+       further indirect enabling condition.
+
 2018-12-20  Keith Marshall  <keith@users.osdn.me>
 
        Implement test suite for aligned heap management API.
index b01570e..d7621b0 100644 (file)
@@ -1,4 +1,3 @@
-#ifndef __MINGW_H
 /*
  * _mingw.h
  *
@@ -31,6 +30,7 @@
  * DEALINGS IN THE SOFTWARE.
  *
  */
+#ifndef __MINGW_H
 #define __MINGW_H
 
 /* In previous versions, __MINGW32_VERSION was expressed as a dotted
@@ -374,30 +374,34 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
 
 /* Activation of MinGW specific extended features:
  */
-#ifndef __USE_MINGW_ANSI_STDIO
+#ifdef __USE_MINGW_ANSI_STDIO
 /* Users should not set this directly; rather, define one (or more)
  * of the feature test macros (tabulated below), or specify any of the
  * compiler's command line options, (e.g. -posix, -ansi, or -std=c...),
  * which cause _POSIX_SOURCE, or __STRICT_ANSI__ to be defined.
- *
- * We must check this BEFORE we specifiy any implicit _POSIX_C_SOURCE,
+ */
+# warning "Direct definition of __USE_MINGW_ANSI_STDIO is deprecated."
+# pragma message "See <_mingw.h> for preferred feature activation methods."
+
+#else  /* ! defined __USE_MINGW_ANSI_STDIO */
+/* We must check this BEFORE we specifiy any implicit _POSIX_C_SOURCE,
  * otherwise we would always implicitly choose __USE_MINGW_ANSI_STDIO,
  * even if none of these selectors are specified explicitly...
  */
-# if   defined __STRICT_ANSI__  ||  defined _ISOC99_SOURCE \
-   ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE \
-   ||  defined _XOPEN_SOURCE    ||  defined _XOPEN_SOURCE_EXTENDED \
-   ||  defined _GNU_SOURCE      ||  defined _BSD_SOURCE \
-   ||  defined _SVID_SOURCE
-   /*
-    * but where any of these source code qualifiers are specified,
-    * then assume ANSI I/O standards are preferred over Microsoft's...
-    */
-#  define __USE_MINGW_ANSI_STDIO    1
+# if  defined __STRICT_ANSI__  ||  defined _SVID_SOURCE            \
+  ||  defined _ISOC99_SOURCE   ||  defined _ISOC11_SOURCE          \
+  ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE         \
+  ||  defined _XOPEN_SOURCE    ||  defined _XOPEN_SOURCE_EXTENDED  \
+  ||  defined _GNU_SOURCE      ||  defined _BSD_SOURCE
+  /*
+   * but where any of these source code qualifiers are specified,
+   * then assume ANSI I/O standards are preferred over Microsoft's...
+   */
+#  define __USE_MINGW_ANSI_STDIO   __MINGW_ANSI_STDIO__
 # else
-   /* otherwise use whatever __MINGW_FEATURES__ specifies...
-    */
-#  define __USE_MINGW_ANSI_STDIO    (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
+  /* otherwise use whatever __MINGW_FEATURES__ specifies...
+   */
+#  define __USE_MINGW_ANSI_STDIO  (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
 # endif
 #endif