Hello all,
I have tried to build the flashrom with mingw on Windows, but the build process fails with:
flash.h:336:1: error: '__MINGW_PRINTF_FORMAT' is an unrecognized format function type [-Werror=format=] __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)));
I have checked the stdio.h shipped with the mingw installation, but it does not contains the __MINGW_PRINTF_FORMAT macro.
I have used the latest available mingw-get-setup, because the 20110530 version (which mentioned in the wiki as known t obe working) segfaults when I select the MSYS Basic System feature.
I can build with WARNERROR=no, but some more permanent fix recommentation would be warmly welcome!
On Fri, 19 Jan 2018 00:38:53 +0100 Miklos Marton martonmiklosqdev@gmail.com wrote:
Hello all,
I have tried to build the flashrom with mingw on Windows, but the build process fails with:
flash.h:336:1: error: '__MINGW_PRINTF_FORMAT' is an unrecognized format function type [-Werror=format=] __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)));
I have checked the stdio.h shipped with the mingw installation, but it does not contains the __MINGW_PRINTF_FORMAT macro.
Hi,
I have been reading about the printf format on MinGW for another project and I run into this message.
Miklos are you still experiencing the problem?
Here on Linux with mingw-w64 version 5.0.3 the constant is here in /usr/share/mingw-w64/include/stdio.h
I have used the latest available mingw-get-setup, because the 20110530 version (which mentioned in the wiki as known t obe working) segfaults when I select the MSYS Basic System feature.
I can build with WARNERROR=no, but some more permanent fix recommentation would be warmly welcome!
I think a change like the following can help:
diff --git a/flash.h b/flash.h index a80a9c2..4ae5808 100644 --- a/flash.h +++ b/flash.h @@ -359,7 +359,7 @@ void start_logging(void); 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__ +#ifdef __MINGW_PRINTF_FORMAT __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3))); #else __attribute__((format(printf, 2, 3)));
In case the constant is not defined the compiler may still give warnings but at least the code will compile.
If the change looks good I can forward it through the proper channels. BTW are patches sent via git-send-email accepted?
Ciao, Antonio
Hi,
I have been reading about the printf format on MinGW for another project and I run into this message.
Miklos are you still experiencing the problem?
Here on Linux with mingw-w64 version 5.0.3 the constant is here in /usr/share/mingw-w64/include/stdio.h
I have used the latest available mingw-get-setup, because the 20110530 version (which mentioned in the wiki as known t obe working) segfaults when I select the MSYS Basic System feature.
I can build with WARNERROR=no, but some more permanent fix recommentation would be warmly welcome!
I think a change like the following can help:
diff --git a/flash.h b/flash.h index a80a9c2..4ae5808 100644 --- a/flash.h +++ b/flash.h @@ -359,7 +359,7 @@ void start_logging(void); 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__ +#ifdef __MINGW_PRINTF_FORMAT __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3))); #else __attribute__((format(printf, 2, 3)));
In case the constant is not defined the compiler may still give warnings but at least the code will compile.
If the change looks good I can forward it through the proper channels. BTW are patches sent via git-send-email accepted?
Ciao, Antonio
Hey Antonio,
Thank you very much for your email, it solves one part of the problem on Windows. Now I got the following warnings:
dummyflasher.c: In function 'dummy_init': dummyflasher.c:379:12: warning: unknown conversion type character 'j' in format [-Wformat=] msg_pdbg("Found persistent image %s, %jd B ", ^ flash.h:350:49: note: in definition of macro 'msg_pdbg' #define msg_pdbg(...) print(FLASHROM_MSG_DEBUG, __VA_ARGS__) /* programmer debug */ ^~~~~~~~~~~ dummyflasher.c:379:12: warning: too many arguments for format [-Wformat-extra-args] msg_pdbg("Found persistent image %s, %jd B ", ^
Best regards, Miklos Marton
On Tue, 27 Feb 2018 20:12:20 +0100 Márton Miklós martonmiklosqdev@gmail.com wrote:
[...]
Hey Antonio,
Thank you very much for your email, it solves one part of the problem on Windows. Now I got the following warnings:
dummyflasher.c: In function 'dummy_init': dummyflasher.c:379:12: warning: unknown conversion type character 'j' in format [-Wformat=] msg_pdbg("Found persistent image %s, %jd B ", ^ flash.h:350:49: note: in definition of macro 'msg_pdbg' #define msg_pdbg(...) print(FLASHROM_MSG_DEBUG, __VA_ARGS__) /* programmer debug */ ^~~~~~~~~~~ dummyflasher.c:379:12: warning: too many arguments for format [-Wformat-extra-args] msg_pdbg("Found persistent image %s, %jd B ", ^
This is one of the possible warnings I was talking about, and it derives from the very fact that __MINGW_PRINTF_FORMAT is not defined in your installation, and the default "printf" format is not enough.
The proper solution would be to get a MinGW version which defines __MINGW_PRINTF_FORMAT, I see that it has been added "only" in 2012 :) https://sourceforge.net/p/mingw-w64/mingw-w64/ci/77bc5d6103b5fb9f59fbddab158...
Anyways, one possible workaround to support older MinGW versions would be to use "gnu_printf" directly as a printf format, like this:
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)));
This should be OK because the define is only applied when using MinGW.
JFYI I decided for a less backward compatible solution in the other project: https://git.ao2.it/libam7xxx.git/commitdiff/bbebd199987581ee6f344c89bfb02237...
Ciao, Antonio
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)));
This should be OK because the define is only applied when using MinGW.
JFYI I decided for a less backward compatible solution in the other project: https://git.ao2.it/libam7xxx.git/commitdiff/bbebd199987581ee6f344c89bfb02237...
Ciao, Antonio
This method compiles without warnings. Thank you very much! Are you planning to submit a patch to flashrom, or should we handle that?
Best regards, Miklos Marton
On Wed, 28 Feb 2018 20:31:13 +0100 Miklos Marton martonmiklosqdev@gmail.com wrote:
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)));
This should be OK because the define is only applied when using MinGW.
[...]
This method compiles without warnings. Thank you very much! Are you planning to submit a patch to flashrom, or should we handle that?
I can do it during the week-end.
Ciao, Antonio