From e42a50da04105827b6dc1d171c4b0a2a55e820a5 Mon Sep 17 00:00:00 2001 From: eugene Date: Wed, 12 May 2021 12:33:36 -0400 Subject: [PATCH 1/2] use proper formatting macros when using MinGW provided stdio add changelog entry Signed-off-by: eugene --- ChangeLog.d/fix-mingw-build.txt | 4 ++++ include/mbedtls/debug.h | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 ChangeLog.d/fix-mingw-build.txt diff --git a/ChangeLog.d/fix-mingw-build.txt b/ChangeLog.d/fix-mingw-build.txt new file mode 100644 index 0000000000..b5255beb38 --- /dev/null +++ b/ChangeLog.d/fix-mingw-build.txt @@ -0,0 +1,4 @@ +Changes + * fix build failure on MinGW toolchain when __USE_MING_ANSI_STDIO is on. + When that flag is on, standard GNU C printf format specifiers should be used. + diff --git a/include/mbedtls/debug.h b/include/mbedtls/debug.h index c8d4403d80..71b08295d6 100644 --- a/include/mbedtls/debug.h +++ b/include/mbedtls/debug.h @@ -98,8 +98,13 @@ */ #if defined(__has_attribute) #if __has_attribute(format) +#if defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \ - __attribute__((format (printf, string_index, first_to_check))) + __attribute__((__format__ (gnu_printf, string_index, first_to_check))) +#else /* defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1 */ +#define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \ + __attribute__((format(printf, string_index, first_to_check))) +#endif #else /* __has_attribute(format) */ #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) #endif /* __has_attribute(format) */ @@ -119,14 +124,14 @@ * * This module provides debugging functions. */ -#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1800) +#if (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) #include #define MBEDTLS_PRINTF_SIZET PRIuPTR #define MBEDTLS_PRINTF_LONGLONG "I64d" -#else /* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1800) */ +#else /* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */ #define MBEDTLS_PRINTF_SIZET "zu" #define MBEDTLS_PRINTF_LONGLONG "lld" -#endif /* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1800) */ +#endif /* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */ #ifdef __cplusplus extern "C" { From b46d1a74f92b8873be59f93873a3cccc1a905f22 Mon Sep 17 00:00:00 2001 From: eugene Date: Wed, 12 May 2021 14:36:24 -0400 Subject: [PATCH 2/2] fix changelog entry Signed-off-by: eugene --- ChangeLog.d/fix-mingw-build.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.d/fix-mingw-build.txt b/ChangeLog.d/fix-mingw-build.txt index b5255beb38..383b1c7fd4 100644 --- a/ChangeLog.d/fix-mingw-build.txt +++ b/ChangeLog.d/fix-mingw-build.txt @@ -1,4 +1,5 @@ Changes * fix build failure on MinGW toolchain when __USE_MING_ANSI_STDIO is on. - When that flag is on, standard GNU C printf format specifiers should be used. + When that flag is on, standard GNU C printf format specifiers + should be used.