The __MINGW_PRINTF_FORMAT constant has been defined back in 2012 https://sourceforge.net/p/mingw-w64/mingw-w64/ci/77bc5d6103b5fb9f59fbddab158...
However older toolchains are still around and some user reported the following compilation failure:
flash.h:336:1: error: '__MINGW_PRINTF_FORMAT' is an unrecognized format function type [-Werror=format=] __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)));
Fix this by defining the constant when it isn't already; the change does not affect other compilers because it's guarded by "#ifdef __MINGW32__".
Setting __MINGW_PRINTF_FORMAT to gnu_printf is exactly what newer MinGW versions do when __USE_MINGW_ANSI_STDIO is defined, which it is in flashrom Makefile.
Tested-by: Miklos Marton martonmiklosqdev@gmail.com Signed-off-by: Antonio Ospite ao2@ao2.it --- flash.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/flash.h b/flash.h index a80a9c2..40a7f1a 100644 --- a/flash.h +++ b/flash.h @@ -360,6 +360,9 @@ int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap /* Let gcc and clang check for correct printf-style format strings. */ int print(enum flashrom_log_level level, const char *fmt, ...) #ifdef __MINGW32__ +# ifndef __MINGW_PRINTF_FORMAT +# define __MINGW_PRINTF_FORMAT gnu_printf +# endif __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3))); #else __attribute__((format(printf, 2, 3)));
On Sat, 3 Mar 2018 19:07:15 +0100 Antonio Ospite ao2@ao2.it wrote:
The __MINGW_PRINTF_FORMAT constant has been defined back in 2012 https://sourceforge.net/p/mingw-w64/mingw-w64/ci/77bc5d6103b5fb9f59fbddab158...
However older toolchains are still around and some user reported the following compilation failure:
flash.h:336:1: error: '__MINGW_PRINTF_FORMAT' is an unrecognized format function type [-Werror=format=] __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)));
Fix this by defining the constant when it isn't already; the change does not affect other compilers because it's guarded by "#ifdef __MINGW32__".
Setting __MINGW_PRINTF_FORMAT to gnu_printf is exactly what newer MinGW versions do when __USE_MINGW_ANSI_STDIO is defined, which it is in flashrom Makefile.
Tested-by: Miklos Marton martonmiklosqdev@gmail.com Signed-off-by: Antonio Ospite ao2@ao2.it
Pushed also to gerrit: https://review.coreboot.org/c/flashrom/+/25130
Ciao, Antonio
flash.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/flash.h b/flash.h index a80a9c2..40a7f1a 100644 --- a/flash.h +++ b/flash.h @@ -360,6 +360,9 @@ int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap /* Let gcc and clang check for correct printf-style format strings. */ int print(enum flashrom_log_level level, const char *fmt, ...) #ifdef __MINGW32__ +# ifndef __MINGW_PRINTF_FORMAT +# define __MINGW_PRINTF_FORMAT gnu_printf +# endif __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3))); #else __attribute__((format(printf, 2, 3))); -- 2.16.2