Use __MINGW_PRINTF_FORMAT for printf attributes.

MinGW has two different versions of printf. We want the format string
warnings to match. This silences some warnings in the Android build.

Note this assumes that, for external calls of these functions, the build
configuration of the consumer and BoringSSL match in this regard. (But
it doesn't actually matter because the issue is only on XP.)

Change-Id: I7f12ad2fc94130edd984feac5914f8ca6c88b8d4
Commit-Queue: David Benjamin <>
Commit-Queue: Adam Langley <>
CQ-Verified: CQ bot account: <>
Reviewed-by: Adam Langley <>
diff --git a/include/openssl/base.h b/include/openssl/base.h
index 888b594..10a22ce 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -60,6 +60,11 @@
 #include <stdint.h>
 #include <sys/types.h>
+#if defined(__MINGW32__)
+/* stdio.h is needed on MinGW for __MINGW_PRINTF_FORMAT. */
+#include <stdio.h>
 #include <openssl/opensslconf.h>
 #if defined(BORINGSSL_PREFIX)
@@ -158,8 +163,17 @@
 #if defined(__GNUC__)
+/* MinGW has two different printf implementations. Ensure the format macro
+ * matches the selected implementation. See
+ * */
+#if defined(__MINGW_PRINTF_FORMAT)
 #define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \
-        __attribute__((__format__(__printf__, string_index, first_to_check)))
+  __attribute__(                                                 \
+      (__format__(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
+#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \
+  __attribute__((__format__(__printf__, string_index, first_to_check)))
 #define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check)