Fix size_t and longlong specifiers for MinGW

MinGW and older windows compilers cannot cope with %zu or %lld (there is
a workaround for MinGW, but it involves linking more code, there is no
workaround for Windows compilers prior to 2013). Attempt to work around
this by defining printf specifiers for size_t per platform for the
compilers that cannot use the C99 specifiers.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/include/mbedtls/debug.h b/include/mbedtls/debug.h
index 168f70d..c19503f 100644
--- a/include/mbedtls/debug.h
+++ b/include/mbedtls/debug.h
@@ -99,6 +99,34 @@
 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
 #endif
 
+/**
+ * \def MBEDTLS_PRINTF_SIZET
+ *
+ * MBEDTLS_PRINTF_xxx: Due to issues with older window compilers
+ * and MinGW we need to define the printf specifier for size_t
+ * and long long per platform.
+ *
+ * Module:  library/debug.c
+ * Caller:
+ *
+ * This module provides debugging functions.
+ */
+#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1800)
+   #ifdef _WIN32
+      #include <inttypes.h>
+      #ifdef _WIN64
+         #define MBEDTLS_PRINTF_SIZET     PRIuPTR
+         #define MBEDTLS_PRINTF_LONGLONG  "I128d"
+      #else
+         #define MBEDTLS_PRINTF_SIZET     PRIuPTR
+         #define MBEDTLS_PRINTF_LONGLONG  "I64d"
+      #endif
+   #endif
+#else
+   #define MBEDTLS_PRINTF_SIZET     "zu"
+   #define MBEDTLS_PRINTF_LONGLONG  "lld"
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif