+#define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __Wformat(F)
+#define __Wformat_mingw_printf(F,A) __attribute__((__format__(__mingw_printf__,F,A)))
+
+#if __GNUC__ >= 6
+/* From GCC-6 onwards, we will provide customized -Wformat
+ * handling, via our own mingw_printf format category...
+ */
+#define __Wformat(F) __Wformat_##F __mingw_##F
+
+#else /* __GNUC__ < 6 */
+/* ...whereas, for earlier GCC, we preserve the status quo,
+ * offering no -Wformat checking for those functions which
+ * replace the MSVCRT.DLL versions...
+ */
+#define __Wformat(F) __mingw_##F
+/*
+ * ...while degrading to gnu_printf checking for snprintf()
+ * and vsnprintf(), (which are ALWAYS MinGW.org variants).
+ */
+#define __mingw_printf__ __gnu_printf__
+#endif
+
+/* The following convenience macros specify the appropriate
+ * -Wformat checking for MSVCRT.DLL replacement functions...
+ */
+#define __Wformat_printf __Wformat_mingw_printf(1,2)
+#define __Wformat_fprintf __Wformat_mingw_printf(2,3)
+#define __Wformat_sprintf __Wformat_mingw_printf(2,3)
+#define __Wformat_vprintf __Wformat_mingw_printf(1,0)
+#define __Wformat_vfprintf __Wformat_mingw_printf(2,0)
+#define __Wformat_vsprintf __Wformat_mingw_printf(2,0)
+/*
+ * ...while this pair are specific to the two MinGW.org
+ * only functions.
+ */
+#define __Wformat_snprintf __Wformat_mingw_printf(3,4)
+#define __Wformat_vsnprintf __Wformat_mingw_printf(3,0)